:root {
  color-scheme: dark;
  font-family: "Poppins", system-ui, sans-serif;
  background: #06080d;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #0b1b2b, #05070d 60%);
  color: #fff;
}

.app {
  width: min(100%, 1200px);
  padding: 2rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

.brand__logo {
  font-weight: 600;
  text-transform: uppercase;
}

.brand__logo--luminix {
  color: #0fffc1;
}

.brand__logo--lumiscore {
  color: #0ecbff;
  font-size: 1.2rem;
}

.brand__logo-image {
  width: 250px;
  height: 250px;
  object-fit: contain;
  display: block;
  margin-bottom: 0.25rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: transparent !important;
}

.scoreboard {
  background: linear-gradient(145deg, #0f2339, #0b1523);
  padding: 1.5rem;
  border-radius: 24px;
  box-shadow: 0 25px 45px rgba(0, 0, 0, 0.5);
  display: grid;
  grid-template-columns: repeat(6, minmax(100px, 1fr));
  grid-auto-rows: minmax(100px, auto);
  gap: 1rem;
  position: relative;
}

.scoreboard__panel {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  font-family: "Orbitron", "Poppins", sans-serif;
}

.scoreboard__panel--team {
  grid-column: span 2;
  background: linear-gradient(45deg, rgba(26, 80, 255, 0.35), rgba(255, 255, 255, 0.03));
}

.team-players {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.player-name {
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1;
  text-align: left;
}
#teamA1Name, #teamA2Name {
  background: linear-gradient(180deg, rgba(255,255,255,0.9), #2a47ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 8px rgba(42, 71, 255, 0.35);
}
#teamB1Name, #teamB2Name {
  background: linear-gradient(180deg, rgba(255,255,255,0.9), #00ff85);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 8px rgba(0, 255, 133, 0.35);
}

.player-name.serve {
  display: inline-block;
  animation: serve-pulse 1.6s ease-in-out infinite, serve-blink 1.6s ease-in-out infinite;
  text-shadow: 0 0 6px rgba(255,255,255,0.6);
  position: relative;
}

.player-name.serve::after {
  content: "";
  margin-left: 0.35rem;
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 11px solid #ffffff;
  box-shadow: 0 0 2px #ffffff, 0 0 6px rgba(255,255,255,0.85);
  animation: cock-blink 1.6s ease-in-out infinite;
  vertical-align: middle;
  transform: translateY(-2px);
}

.player-position {
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #8ba3c2;
  min-width: 50px;
  text-align: center;
}
.player-position.pos-serve.team-a {
  color: #2a47ff;
  text-shadow: 0 0 8px rgba(42, 71, 255, 0.45);
}
.player-position.pos-receive.team-a {
  color: #0ecbff;
  text-shadow: 0 0 8px rgba(14, 203, 255, 0.45);
}
.player-position.pos-serve.team-b {
  color: #00ff85;
  text-shadow: 0 0 8px rgba(0, 255, 133, 0.45);
}
.player-position.pos-receive.team-b {
  color: #ffd54d;
  text-shadow: 0 0 8px rgba(255, 213, 77, 0.45);
}

.player-position.position-right {
  background: rgba(0, 255, 127, 0.2);
  color: #00ff85;
  font-weight: 600;
}

.player-position.position-left {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.scoreboard__panel--time {
  grid-column: span 2;
  background: linear-gradient(45deg, rgba(14, 226, 255, 0.25), rgba(255, 255, 255, 0.06));
}

.scoreboard__panel--score {
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  font-weight: 600;
  background: radial-gradient(circle, rgba(255, 0, 0, 0.3), rgba(0, 0, 0, 0.1));
  color: #ff542c;
}

.scoreboard__panel--score:last-of-type {
  background: radial-gradient(circle, rgba(0, 255, 127, 0.35), rgba(0, 0, 0, 0.1));
  color: #00ff85;
}

.scoreboard__panel--sets {
  grid-column: span 2;
  font-size: 1.2rem;
}

.scoreboard__panel--sets .sets {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.scoreboard__panel .label {
  text-transform: uppercase;
  font-size: 0.68rem;
  color: #8ba3c2;
  letter-spacing: 0.08em;
}

.scoreboard__panel h2 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 600;
}

.scoreboard__panel h3 {
  margin: 0.5rem 0;
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  letter-spacing: 0.1em;
}
.scoreboard__panel--time h3 {
  font-size: 2.2rem;
  letter-spacing: 0.06em;
}

.scoreboard__panel .status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.service {
  grid-column: span 6;
  text-align: center;
  padding: 0.75rem;
  background: rgba(0, 255, 127, 0.1);
  border-radius: 12px;
  margin-top: 0.5rem;
}

.service-indicators {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.service-indicator {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #8ba3c2;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
  min-width: 50px;
  text-align: center;
}

.service-indicator.active {
  background: linear-gradient(145deg, rgba(0, 255, 127, 0.4), rgba(0, 255, 127, 0.2));
  color: #00ff85;
  box-shadow: 0 0 15px rgba(0, 255, 127, 0.3);
  transform: scale(1.1);
}

.bot {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bot header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bot button {
  background: #0ecbff;
  border: none;
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.bot button:hover {
  opacity: 0.85;
}

.bot ul {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bot li {
  background: rgba(14, 226, 255, 0.08);
  border-left: 3px solid #0ecbff;
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.bot time {
  color: #8ba3c2;
  font-size: 0.8rem;
}

.notif-time {
  color: #8ba3c2;
  font-size: 0.8rem;
  margin-right: 0.5rem;
}

.notice {
  min-height: 1.25rem;
  color: #0fffc1;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: opacity 0.3s ease;
}

.controller__actions .notice {
  grid-column: span 2;
}

.btn-success-flash {
  box-shadow: 0 0 18px rgba(14, 226, 255, 0.6), inset 0 0 12px rgba(255, 255, 255, 0.2);
  filter: saturate(1.4);
}

@media (max-width: 900px) {
  .scoreboard {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .scoreboard__panel--team,
  .scoreboard__panel--time,
  .scoreboard__panel--sets {
    grid-column: span 2;
  }

  .service {
    grid-column: span 2;
  }

  .player-name {
    font-size: 1rem;
  }

  .player-position {
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
    min-width: 45px;
  }

  .service-indicators {
    gap: 0.5rem;
  }

  .service-indicator {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    min-width: 45px;
  }
}

@media (max-width: 600px) {
  .scoreboard {
    grid-template-columns: repeat(3, minmax(90px, 1fr));
    gap: 0.75rem;
  }
  .scoreboard__panel--team,
  .scoreboard__panel--time,
  .scoreboard__panel--sets {
    grid-column: span 1;
  }
  .service {
    grid-column: span 3;
  }
  .scoreboard__panel h3 {
    font-size: clamp(1.2rem, 5vw, 1.6rem);
  }
  .scoreboard__panel--time h3 { font-size: 1.7rem; letter-spacing: 0.05em; }
  .scoreboard__panel--score {
    font-size: clamp(1.7rem, 8.5vw, 2.6rem);
    justify-content: center;
  }
  .scoreboard__panel--score .label { margin-bottom: 0.35rem; }
}
  .scoreboard__panel--sets { font-size: 0.85rem; }
  .scoreboard__panel { padding: 0.85rem; }
  .scoreboard__panel--sets .sets { gap: 0.25rem; flex-wrap: nowrap; }
  .set-wins { font-size: 2.1rem; }
  .set-scores { font-size: 0.75rem; min-width: 5ch; }
}
  .scoreboard__panel .label { font-size: 0.65rem; }
  .player-name { font-size: 0.95rem; }
  .player-position { font-size: 0.7rem; padding: 0.18rem 0.35rem; }
}

.powered-by {
  color: #8ba3c2;
  font-size: 0.85rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  overflow-y: auto;
}
.overlay.visible {
  display: flex;
}
.overlay__content {
  background: linear-gradient(145deg, rgba(14, 226, 255, 0.2), rgba(255, 255, 255, 0.08));
  border: 2px solid rgba(14, 226, 255, 0.5);
  border-radius: 20px;
  padding: 1.5rem 2rem;
  text-align: center;
  box-shadow: 0 25px 45px rgba(0,0,0,0.5);
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}
.overlay__content h2 {
  margin: 0;
  font-family: "Orbitron", "Poppins", sans-serif;
  font-size: clamp(2rem, 6vw, 3rem);
  letter-spacing: 0.1em;
}
.overlay__name {
  margin-top: 0.5rem;
  font-family: "Orbitron", "Poppins", sans-serif;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  letter-spacing: 0.08em;
}
.overlay__score {
  margin-top: 0.35rem;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  color: #8ba3c2;
}

/* Celebrate animation for score bump */
.celebrate {
  animation: pop 420ms ease;
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.4));
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@keyframes serve-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes serve-blink {
  0% { opacity: 1; }
  50% { opacity: 0.92; }
  100% { opacity: 1; }
}

@keyframes hand-blink {
  0% { opacity: 1; }
  50% { opacity: 0.85; }
  100% { opacity: 1; }
}

@keyframes hand-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes cock-blink {
  0% { opacity: 1; }
  50% { opacity: 0.85; }
  100% { opacity: 1; }
}
.overlay__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  cursor: pointer;
  font-size: 18px;
  line-height: 26px;
  text-align: center;
}

/* History Overlay Specific Styling */
#historyOverlay .overlay__content {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  max-width: 95vw;
  padding: 1.5rem;
  overflow: visible;
}

#historyOverlay .overlay__content h2 {
  margin-bottom: 1rem;
  flex-shrink: 0;
}

#historyOverlay #historyList {
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
  max-height: calc(85vh - 120px);
  scrollbar-width: thin;
  scrollbar-color: rgba(14, 226, 255, 0.5) rgba(0, 0, 0, 0.2);
}

#historyOverlay #historyList::-webkit-scrollbar {
  width: 8px;
}

#historyOverlay #historyList::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

#historyOverlay #historyList::-webkit-scrollbar-thumb {
  background: rgba(14, 226, 255, 0.5);
  border-radius: 4px;
}

#historyOverlay #historyList::-webkit-scrollbar-thumb:hover {
  background: rgba(14, 226, 255, 0.8);
}

/* Ensure confetti pieces render above content, especially on mobile */
.confetti-piece {
  position: fixed;
  z-index: 9998;
  pointer-events: none;
  backface-visibility: hidden;
}
.set-wins {
  font-size: 3.6rem;
}
.set-scores {
  font-size: 1.05rem;
  color: #8ba3c2;
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 7ch;
}
.set-score { display: block; white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1.2; }
.set-space { display: none; }
.set-scores--left {
  margin-right: 0.3rem;
  text-align: right;
}
.set-scores--right {
  margin-left: 0.3rem;
  text-align: left;
}
.set-score { line-height: 1.1; }
