*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --clay:       #B85530;
  --clay-dark:  #6B2B14;
  --clay-deep:  #1C0802;
  --chalk:      #F2E4D0;
  --chalk-dim:  rgba(242, 228, 208, 0.45);
  --gold:       #E8B840;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--clay-dark);
}

/* ── COURT ─────────────────────────── */
.court {
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--clay);
  overflow: hidden;
}

/* clay texture */
.court::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.04) 3px,
    rgba(0,0,0,0.04) 4px
  );
  pointer-events: none;
  z-index: 0;
}

/* court lines */
.court-line {
  position: absolute;
  left: 4%;
  right: 4%;
  height: 1px;
  background: rgba(242, 228, 208, 0.3);
  z-index: 1;
}
.court-line-top    { top: 32px; }
.court-line-bottom { bottom: 72px; }

.court-line-center {
  position: absolute;
  top: 32px;
  bottom: 72px;
  left: 50%;
  width: 1px;
  background: rgba(242, 228, 208, 0.25);
  transform: translateX(-50%);
  z-index: 1;
}

/* ── PLAYERS GRID ──────────────────── */
.players {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 180px 1fr;
  position: relative;
  z-index: 2;
}

/* ── PLAYER PANELS ─────────────────── */
.player-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  transition: background 0.6s ease;
  background: linear-gradient(
    to bottom,
    rgba(28, 8, 2, 0.65) 0%,
    rgba(28, 8, 2, 0.15) 45%,
    rgba(28, 8, 2, 0.05) 70%,
    rgba(28, 8, 2, 0.55) 100%
  );
}

.panel-winner .panel-overlay {
  background: linear-gradient(
    to bottom,
    rgba(28, 8, 2, 0.45) 0%,
    rgba(28, 8, 2, 0.05) 45%,
    rgba(28, 8, 2, 0.0)  70%,
    rgba(28, 8, 2, 0.35) 100%
  );
}

.panel-loser .panel-overlay {
  background: linear-gradient(
    to bottom,
    rgba(28, 8, 2, 0.82) 0%,
    rgba(28, 8, 2, 0.55) 45%,
    rgba(28, 8, 2, 0.35) 70%,
    rgba(28, 8, 2, 0.75) 100%
  );
}

/* photos */
.player-photo {
  position: absolute;
  bottom: 60px;
  width: 78%;
  max-height: 88%;
  object-fit: contain;
  object-position: bottom center;
  z-index: 0;
}

.panel-sinner  .player-photo { right: -4%; }
.panel-alcaraz .player-photo { left: -4%; }

.panel-loser .player-photo { opacity: 0.6; filter: saturate(0.5); }
.panel-winner .player-photo { opacity: 1; filter: saturate(1.1); }

/* player info */
.player-content {
  position: relative;
  z-index: 2;
  padding: 52px 36px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.player-content-right { align-items: flex-end; text-align: right; }

.player-flag {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}
.player-nat {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--chalk-dim);
  text-transform: uppercase;
}
.player-firstname {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 3px;
  color: rgba(242, 228, 208, 0.5);
  text-transform: uppercase;
  margin-top: 2px;
}
.player-name {
  font-size: clamp(40px, 5.5vw, 76px);
  font-weight: 900;
  color: var(--chalk);
  text-transform: uppercase;
  letter-spacing: -1px;
  line-height: 1;
  margin: 6px 0 12px;
}

/* ghost win numbers */
.player-wins {
  position: absolute;
  bottom: 72px;
  right: 24px;
  font-size: clamp(100px, 16vw, 200px);
  font-weight: 900;
  color: var(--chalk);
  opacity: 0.07;
  line-height: 1;
  z-index: 1;
  user-select: none;
}
.player-wins-right {
  right: auto;
  left: 24px;
}

/* badges */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 5px 13px;
  border-radius: 100px;
}
.badge-winner {
  background: var(--gold);
  color: var(--clay-deep);
}
.badge-leader {
  background: transparent;
  border: 1px solid var(--chalk-dim);
  color: var(--chalk-dim);
}
/* match history watermark */
.match-history {
  position: absolute;
  top: 50%;
  left: 28px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 0;
  opacity: 0.18;
  user-select: none;
  pointer-events: none;
}
.match-history-right {
  left: auto;
  right: 28px;
  align-items: flex-end;
}
.match-history span {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--chalk);
  white-space: nowrap;
}
.panel-loser .match-history { opacity: 0.35; }

.panel-badges {
  position: absolute;
  bottom: 88px;
  left: 32px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel-badges-right {
  left: auto;
  right: 32px;
  align-items: flex-end;
}
.hidden { display: none !important; }

/* ── CENTER COLUMN ─────────────────── */
.center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: relative;
  z-index: 3;
  padding: 20px 0;
}

.rivalry-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--chalk-dim);
}

.record {
  display: flex;
  align-items: center;
  gap: 6px;
}
.record-num {
  font-size: clamp(44px, 5vw, 68px);
  font-weight: 900;
  color: var(--chalk);
  line-height: 1;
}
.record-sep {
  font-size: 28px;
  color: var(--chalk-dim);
  font-weight: 300;
  margin-bottom: 4px;
}
.record-names {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0 6px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--chalk-dim);
  text-transform: uppercase;
}

/* ── LAST MATCH BAR ────────────────── */
.last-match-bar {
  background: rgba(20, 6, 1, 0.75);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(242, 228, 208, 0.12);
  padding: 14px 40px;
  z-index: 10;
  position: relative;
}

.last-match-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 960px;
  margin: 0 auto;
}

.lm-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--chalk-dim);
  margin-right: 6px;
  flex-shrink: 0;
}
.lm-winner {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.lm-def {
  font-size: 11px;
  color: var(--chalk-dim);
  font-style: italic;
}
.lm-loser {
  font-size: 13px;
  font-weight: 700;
  color: var(--chalk);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.lm-score {
  font-size: 13px;
  font-weight: 700;
  color: var(--chalk);
  padding: 2px 10px;
  border: 1px solid rgba(242, 228, 208, 0.2);
  border-radius: 4px;
  margin-left: 4px;
  flex-shrink: 0;
}
.lm-event {
  font-size: 11px;
  color: var(--chalk-dim);
  margin-left: auto;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

/* ── ANIMATIONS ────────────────────── */
@keyframes photoFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

.photo-entrance {
  animation: photoFadeIn 0.6s ease forwards, photoBob 3.2s ease-in-out 0.6s 2;
}

/* ── RESPONSIVE ────────────────────── */
@media (max-width: 768px) {
  html, body { overflow: auto; }

  .court { height: auto; min-height: 100vh; }

  .players {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .player-panel { min-height: 55vw; }
  .player-photo { width: 55%; bottom: 0; }
  .player-wins  { font-size: 80px; bottom: 0; }

  .center-col {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    padding: 24px 20px;
    gap: 16px;
    background: rgba(28, 8, 2, 0.5);
  }

  .last-match-inner {
    flex-wrap: wrap;
    gap: 6px;
  }
  .lm-event { margin-left: 0; }
}
