@font-face {
  font-family: 'Horta';
  src: url('/fonts/Horta.woff2') format('woff2'),
       url('/fonts/Horta.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  --accent: #e2341f;
  --accent-glow: rgba(226, 52, 31, 0.65);
  --accent-gold: #f0b429;
  --panel-bg: rgba(10, 14, 18, 0.82);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: transparent;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Horta', 'Poppins', 'Segoe UI', sans-serif;
  color: var(--text);
}

#app {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hidden { display: none !important; }

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* liveState's children (set-history/scoreboard/historyRow) muszą mieć tę
   samą szerokość co najszerszy z nich, inaczej węższe elementy nie zakrywają
   rogów szerszych i wyglądają jakby nie były zaokrąglone. */
#liveState { align-items: stretch; }

/* ---------- Waiting state ---------- */
#waitingState {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 22px 40px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
#waitingLogo { width: 64px; height: 64px; object-fit: contain; border-radius: 50%; margin-bottom: 8px; }
#waitingVenue { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; opacity: 0.9; }
.waitingText { font-size: 14px; color: var(--text-dim); margin-top: 4px; }

/* ---------- Header ---------- */
#header {
  position: fixed;
  top: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 30px 14px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.clubBadge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 3px solid var(--accent);
  flex-shrink: 0;
}
.clubLogoImg { width: 100%; height: 100%; object-fit: contain; }
.tournamentInfo { display: flex; flex-direction: column; line-height: 1.3; }
#tournamentName { font-size: 22px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
#roundTable { font-size: 15px; color: var(--text-dim); }

/* ---------- Set history pills ---------- */
.set-history {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  min-height: 30px;
  padding: 6px 16px;
  background: rgba(10, 14, 18, 0.6);
  border: 1px solid var(--panel-border);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
}
.set-pill {
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text-dim);
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: transform 450ms cubic-bezier(.34, 1.56, .64, 1),
              opacity 350ms ease,
              border-color 400ms ease,
              box-shadow 400ms ease;
  white-space: nowrap;
}
.set-pill .sep { opacity: 0.5; padding: 0 2px; }
.set-pill.entering {
  opacity: 0;
  transform: translateY(-26px) scale(0.8);
}
.set-pill.highlight {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}

/* ---------- Scoreboard ---------- */
#scoreboard {
  display: flex;
  align-items: center;
  gap: 22px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-top: none;
  padding: 14px 26px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.playerBlock {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}
.playerBlock.playerA { justify-content: flex-end; }
.playerBlock.playerB { justify-content: flex-start; }

.playerPhoto {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--accent);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
}

.playerInfo { display: flex; flex-direction: column; line-height: 1.3; }
.playerBlock.playerA .playerInfo { align-items: flex-end; text-align: right; }
.playerBlock.playerB .playerInfo { align-items: flex-start; text-align: left; }

.playerName { font-size: 22px; }
.playerName .first { font-weight: 500; opacity: 0.8; }
.playerName .last { font-weight: 800; }

.playerStats {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--accent-gold);
  margin-top: 2px;
}

.flag { width: 28px; height: 20px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,255,255,0.2); flex-shrink: 0; }

.scoreCenter { display: flex; flex-direction: column; align-items: center; min-width: 140px; }

.scoreLabel, .currentSetLabel {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-gold);
}
.scoreLabel { margin-bottom: 2px; }
.currentSetLabel { margin-top: 8px; font-size: 10px; opacity: 0.9; }

.setsScore {
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  display: inline-block;
  transform: scale(1);
}
.setsScore .sep { opacity: 0.4; padding: 0 6px; }
.currentSetScore {
  margin-top: 2px;
  font-size: 18px;
  color: var(--text-dim);
}
.currentSetScore .sep { opacity: 0.5; padding: 0 4px; }
.currentSetScore #curA, .currentSetScore #curB { color: var(--text); font-weight: 700; }

.pulse { animation: pulseAnim 550ms ease; }
@keyframes pulseAnim {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.22); color: var(--accent); text-shadow: 0 0 18px var(--accent-glow); }
  100% { transform: scale(1); }
}

/* ---------- Player history ---------- */
#liveState:has(#historyRow.hidden) #scoreboard {
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
}
#liveState:has(#setHistory.hidden) #scoreboard {
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
}

#historyRow {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  width: 100%;
  background: rgba(10, 14, 18, 0.68);
  border: 1px solid var(--panel-border);
  border-top: none;
  border-radius: 0 0 14px 14px;
  padding: 8px 22px 10px;
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 11px;
  color: var(--text-dim);
  max-width: 260px;
}
.history-list li {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.6;
}
#historyA { text-align: right; }
#historyB { text-align: left; }
