/* Public Scoreboard Styles */

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

body {
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%) !important;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 100vh;
}

/* Main Layout */
#ScoreboardLayout {
  position: relative;
  box-sizing: border-box;
  padding: 0;
  display: grid;
  grid-template-columns: 10vw 1fr 1fr 10vw;
  grid-template-rows: 4vh 9vh 38vh 2vh 10vh 18vh;
  height: 100vh;
  width: 100%;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 100%);
  gap: 0;
  column-gap: 2vw;
  row-gap: 2vh;
}

/* Fullscreen & Frames Buttons */
#FullscreenBtn { 
  position: absolute;
  top: 2%;
  right: 2%;
  background: rgba(40, 40, 40, 0.9);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1.2vh 2.4vh;
  font-size: 1.6vh;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  z-index: 1100;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
#FullscreenBtn:hover { 
  background: rgba(60, 60, 60, 0.95);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

#OpenFramesBtn { 
  position: absolute;
  top: 2%;
  right: 8%;
  background: rgba(40, 40, 40, 0.9);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 1.2vh 2.4vh;
  font-size: 1.6vh;
  font-weight: 600;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: none; /* Hidden since frames are now at bottom */
}
#OpenFramesBtn:hover { 
  background: rgba(60, 60, 60, 0.95);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

/* Venue/Court (row 1 - now at top) */
#VenueCourtRow { 
  grid-column: 1 / span 4;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2vh;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 0 2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Timeouts Section (row 2) */
.timeouts {
  grid-column: 2 / span 2;
  grid-row: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6vw;
  font-size: 7vh;
  margin: 0;
}

/* Score Section (row 3) */
.score-cell {
  grid-column: 2 / span 2;
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6vw;
  position: relative;
}

.score-side {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.score-text { 
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-size: 52vh;
  text-shadow: 0 8px 32px rgba(0, 0, 0, 0.7),
               0 0 50px rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
}

.score-home {
  color: var(--home-primary-color, #FFD700);
  background: linear-gradient(180deg, var(--home-primary-color, #FFD700) 0%, var(--home-secondary-color, #FFA500) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 15px var(--home-primary-color, rgba(255, 215, 0, 0.4)));
}

.score-away {
  color: var(--away-primary-color, #FF3030);
  background: linear-gradient(180deg, var(--away-primary-color, #FF4040) 0%, var(--away-secondary-color, #FF1010) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 15px var(--away-primary-color, rgba(255, 48, 48, 0.4)));
}

/* Balls Container */
.balls-side {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 1vw;
  grid-row: 3;
  padding-top: 2vh;
}

#HomeBalls {
  grid-column: 1;
}

#AwayBalls {
  grid-column: 4;
}

.balls-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5vh;
}

/* Frames Display Under Teams */
.team-frames-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5vh;
  width: 100%;
}

/* Frame History Containers */
.frames-history {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1vh;
  margin: 0;
  max-height: none;
  overflow-y: visible;
  padding: 0;
}

.frames-history::-webkit-scrollbar {
  width: 4px;
}

.frames-history::-webkit-scrollbar-track {
  background: transparent;
}

.frames-history::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.frame-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(30, 30, 30, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 1vh 1vw;
  margin-top: 1vh;
  min-width: 3vw;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.5s ease;
}

.frame-badge.frame-enter {
  animation: frameSlideIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes frameSlideIn {
  0% {
    transform: translateY(-20px) scale(0.8);
    opacity: 0;
  }
  50% {
    transform: translateY(5px) scale(1.05);
    opacity: 0.8;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.frame-badge.home-won {
  border-color: var(--home-primary-color, #FFD700);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 165, 0, 0.1) 100%);
}

.frame-badge.away-won {
  border-color: var(--away-primary-color, #FF3030);
  background: linear-gradient(135deg, rgba(255, 48, 48, 0.15) 0%, rgba(255, 16, 16, 0.1) 100%);
}

.frame-badge-number {
  font-size: 1.4vh;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.2vh;
  letter-spacing: 0.05em;
}

.frame-badge-points {
  font-size: 2.8vh;
  font-weight: 800;
}

.frame-badge.home-won .frame-badge-points {
  color: var(--home-primary-color, #FFD700);
}

.frame-badge.away-won .frame-badge-points {
  color: var(--away-primary-color, #FF3030);
}

/* Frame In Progress - Centered and Bigger */
#FrameInProgress {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 10vw;
  background: linear-gradient(135deg, rgba(20, 20, 20, 0.95) 0%, rgba(10, 10, 10, 0.95) 100%);
  border: 3px solid rgba(92, 255, 92, 0.7);
  border-radius: 16px;
  padding: 2.5vh 2.5vw;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.9),
              0 0 50px rgba(92, 255, 92, 0.4),
              inset 0 1px 5px rgba(92, 255, 92, 0.15);
  transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 100;
}

#FrameInProgress.active {
  display: flex;
  animation: frameInProgressPulse 2s ease-in-out infinite;
}

#FrameInProgress.moving-to-home {
  left: 25%;
  transform: translate(-50%, -50%);
  border-color: var(--home-primary-color, #FFD700);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.9),
              0 0 50px var(--home-primary-color, rgba(255, 215, 0, 0.4)),
              inset 0 1px 5px var(--home-primary-color, rgba(255, 215, 0, 0.15));
}

#FrameInProgress.moving-to-away {
  left: 75%;
  transform: translate(-50%, -50%);
  border-color: var(--away-primary-color, #FF3030);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.9),
              0 0 50px var(--away-primary-color, rgba(255, 48, 48, 0.4)),
              inset 0 1px 5px var(--away-primary-color, rgba(255, 48, 48, 0.15));
}

@keyframes frameInProgressPulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.9),
                0 0 50px rgba(92, 255, 92, 0.4),
                inset 0 1px 5px rgba(92, 255, 92, 0.15);
    border-color: rgba(92, 255, 92, 0.7);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.9),
                0 0 70px rgba(92, 255, 92, 0.6),
                inset 0 2px 8px rgba(92, 255, 92, 0.25);
    border-color: rgba(92, 255, 92, 0.9);
  }
}

.frame-in-progress-label {
  font-size: 2.5vh;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 0.8vh;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}

.frame-in-progress-number {
  font-size: 7vh;
  font-weight: 900;
  color: #5CFF5C;
  display: flex;
  align-items: center;
  gap: 1.2vw;
  text-shadow: 0 0 20px rgba(92, 255, 92, 0.6),
               0 0 40px rgba(92, 255, 92, 0.4),
               0 3px 12px rgba(0, 0, 0, 0.8);
  filter: drop-shadow(0 0 10px rgba(92, 255, 92, 0.5));
}

/* Make frame in progress match frame badge size */
@media (max-width: 1200px) {
  .frame-in-progress-number {
    font-size: 3vh;
  }
}

@media (max-width: 992px) {
  .frame-in-progress-number {
    font-size: 2.8vh;
  }
}

@media (max-width: 768px) {
  .frame-in-progress-number {
    font-size: 2.5vh;
  }
}

@media (max-width: 480px) {
  .frame-in-progress-number {
    font-size: 2.2vh;
  }
}

.frame-in-progress-spinner {
  color: #5CFF5C;
  font-size: 5.5vh;
  animation: spin 1s linear infinite;
  filter: drop-shadow(0 0 10px rgba(92, 255, 92, 0.6));
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.ball-image {
  height: 9vh;
  width: 9vh;
  border-radius: 50%;
  object-fit: contain; /* Consistent display */
  background: rgba(40, 40, 40, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5),
              inset 0 2px 4px rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1); /* Smoother transition */
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.2)); /* Subtle glow */
  padding: 0.3vh; /* Consistent sizing */
  will-change: transform, opacity, filter; /* Performance optimization */
  backface-visibility: hidden; /* Smoother animations */
  perspective: 1000px; /* 3D effect */
}

/* Hovering any ball will subtly highlight all balls */
.balls-container:hover .ball-image {
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
}

/* Animation classes for ball appearance/disappearance */
.ball-enter {
  animation: ballEnter 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.ball-exit {
  animation: ballExit 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes ballEnter {
  0% { 
    opacity: 0;
    transform: scale(0) rotate(-45deg);
    filter: brightness(1.5) drop-shadow(0 0 10px rgba(255,255,255,0.7));
  }
  60% {
    transform: scale(1.2) rotate(var(--random-rotate, 15deg));
  }
  100% { 
    opacity: 1;
    transform: scale(1) rotate(0);
    filter: brightness(1) drop-shadow(0 0 0 transparent);
  }
}

@keyframes ballExit {
  0% { 
    opacity: 1;
    transform: scale(1) rotate(0);
  }
  30% {
    transform: scale(1.1) rotate(calc(var(--random-rotate, -5deg) * -0.5));
  }
  100% { 
    opacity: 0;
    transform: scale(0) rotate(var(--random-rotate, 45deg));
    filter: brightness(0.7);
  }
}

/* Ball hover effect */
.ball-image {
  transition: transform 0.2s ease, filter 0.2s ease;
  cursor: default;
}
.ball-image:hover {
  transform: scale(1.1) translateY(-2px);
  filter: brightness(1.2);
}

.balls-side img[src=""],
.balls-side img:not([src]) {
  display: none;
}

.balls-side img:hover {
  transform: scale(1.05);
}

/* Teams (row 5) */
.team-row {
  grid-column: 2 / span 2;
  grid-row: 5;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 6vw;
  margin-top: 1vh; /* Add space between scores and team names */
}

.timeouts > div {
  display: flex;
  gap: 1.5vw;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.timeouts .fa-clock,
.timeouts .fa-clock-o { 
  color: #fff;
  font-size: inherit;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  opacity: 0.9;
  transition: all 0.3s ease;
}

.timeouts .fa-clock:hover,
.timeouts .fa-clock-o:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Frames Display (row 5 - at bottom) */
/* OLD FRAMES DISPLAY REMOVED - Now showing frames next to balls */

/* Bottom Chronological Frames Display */
#BottomFramesRow {
  grid-column: 1 / span 4;
  grid-row: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2vw;
  row-gap: 1.5vh;
  padding: 2vh 4vw;
  flex-wrap: wrap;
  min-height: 18vh;
  max-height: none;
  overflow: visible;
  align-content: flex-start;
}

.bottom-frame-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 30, 30, 0.85);
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  width: 9vh;
  height: 9vh;
  font-size: 5.5vh;
  font-weight: 900;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  margin: 0.5vh 0;
}

.bottom-frame-badge.home-won {
  color: var(--home-primary-color, #FFD700);
  border-color: var(--home-primary-color, #FFD700);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 165, 0, 0.1) 100%);
  text-shadow: 0 0 15px var(--home-primary-color, #FFD700),
               0 2px 8px rgba(0, 0, 0, 0.8);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5),
              0 0 25px var(--home-primary-color, rgba(255, 215, 0, 0.3));
}

.bottom-frame-badge.away-won {
  color: var(--away-primary-color, #FF3030);
  border-color: var(--away-primary-color, #FF3030);
  background: linear-gradient(135deg, rgba(255, 48, 48, 0.2) 0%, rgba(255, 16, 16, 0.1) 100%);
  text-shadow: 0 0 15px var(--away-primary-color, #FF3030),
               0 2px 8px rgba(0, 0, 0, 0.8);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5),
              0 0 25px var(--away-primary-color, rgba(255, 48, 48, 0.3));
}

.bottom-frame-badge.frame-enter {
  animation: bottomFrameSlideIn 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes bottomFrameSlideIn {
  0% {
    transform: translateY(40px) scale(0.3);
    opacity: 0;
  }
  50% {
    transform: translateY(-10px) scale(1.15);
    opacity: 0.9;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.bottom-frame-badge:hover {
  transform: scale(1.15) translateY(-3px);
  filter: brightness(1.15);
}

.team-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.team-name {
  width: 100%;
  font-weight: 800;
  font-size: 7vh;
  text-align: center;
  line-height: 1.1;
  word-break: break-word;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffffff;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.6),
               0 0 30px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 12vh;
}

.team-name img {
  max-width: 100%;
  max-height: 12vh;
  object-fit: contain;
  max-width: 40vw;
  flex: 1;
}

/* Frames Display (row 5 - at bottom) */
/* OLD FRAMES DISPLAY REMOVED - Now showing frames next to balls */

/* Center Gap - Just spacing, no visual separator */
.center-gap {
  width: 0;
  display: inline-block;
}

/* Modal - Hidden since frames moved to sides */
#FramesModal { 
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
  #ScoreboardLayout {
    grid-template-rows: 4vh 9vh 33vh 2vh 10vh 16vh;
    row-gap: 2vh;
  }
  .score-text { font-size: 45vh; }
  .team-name { font-size: 6vh; }
  .balls-side img { height: 8vh; width: 8vh; }
  .frame-badge { min-width: 3.5vw; }
  .bottom-frame-badge { width: 8.5vh; height: 8.5vh; font-size: 5.2vh; }
  #BottomFramesRow { gap: 1.8vw; padding: 2vh 3vw; row-gap: 1.5vh; min-height: 16vh; }
}

@media (max-width: 1200px) {
  #ScoreboardLayout {
    grid-template-rows: 4vh 8vh 31vh 2vh 9vh 15vh;
    row-gap: 2vh;
  }
  .score-text { font-size: 40vh; }
  .team-name { font-size: 5.5vh; }
  .balls-side img { height: 7vh; width: 7vh; }
  .timeouts { font-size: 6vh; }
  .frame-badge { min-width: 4vw; }
  .bottom-frame-badge { width: 8vh; height: 8vh; font-size: 5vh; }
  #BottomFramesRow { gap: 1.5vw; padding: 2vh 2vw; row-gap: 1.5vh; min-height: 15vh; }
}

@media (max-width: 992px) {
  #ScoreboardLayout {
    grid-template-columns: 4vw 1fr 1fr 4vw;
    grid-template-rows: 6vh 7vh 27vh 6vh 8vh 14vh;
    column-gap: 1.5vw;
    row-gap: 2vh;
  }
  .score-text { font-size: 35vh; }
  .team-name { font-size: 5vh; }
  .balls-side img { height: 6vh; width: 6vh; }
  .timeouts { font-size: 5.5vh; }
  .frame-badge { min-width: 4.5vw; padding: 0.8vh 0.8vw; }
  .frame-badge-points { font-size: 2.4vh; }
  .frame-badge-number { font-size: 1.2vh; }
  #FrameInProgress {
    min-width: 10vw;
    padding: 2.5vh 2.5vw;
  }
  .frame-in-progress-number { font-size: 7vh; }
  .frame-in-progress-label { font-size: 2.6vh; }
  .frame-in-progress-spinner { font-size: 5.5vh; }
  .bottom-frame-badge { width: 7.5vh; height: 7.5vh; font-size: 4.8vh; gap: 1.5vw; }
  #BottomFramesRow { gap: 1.2vw; padding: 1.5vh 2vw; row-gap: 1.5vh; min-height: 14vh; }
}

@media (max-width: 1024px) {
  #ScoreboardLayout {
    grid-template-columns: 6vw 1fr 1fr 6vw;
    grid-template-rows: 5vh 7vh 29vh 6vh 8vh 14vh;
    column-gap: 1.5vw;
    row-gap: 2vh;
  }
  .score-text { font-size: 38vh; }
  .team-name { font-size: 5.2vh; }
  .balls-side img { height: 6.5vh; width: 6.5vh; }
  .timeouts { font-size: 5.8vh; }
  .frame-badge { min-width: 4.2vw; padding: 0.9vh 0.9vw; }
  .frame-badge-points { font-size: 2.6vh; }
  .frame-badge-number { font-size: 1.3vh; }
  #FrameInProgress {
    min-width: 11vw;
    padding: 2.8vh 2.8vw;
  }
  .frame-in-progress-number { font-size: 7.5vh; }
  .frame-in-progress-label { font-size: 2.8vh; }
  .frame-in-progress-spinner { font-size: 5.8vh; }
  .bottom-frame-badge { width: 8vh; height: 8vh; font-size: 5vh; }
  #BottomFramesRow { gap: 1.5vw; padding: 2vh 2vw; row-gap: 1.5vh; min-height: 14vh; }
}

@media (max-width: 768px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }
  
  #ScoreboardLayout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto auto auto auto;
    padding: 2vh 3vw;
    row-gap: 1.5vh;
    height: auto;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
  }
  
  /* Reorganize layout for mobile */
  #VenueCourtRow {
    grid-column: 1;
    grid-row: 1;
    font-size: 2.4vh;
    padding: 1vh 0;
    width: 100%;
  }
  
  .score-cell {
    grid-column: 1;
    grid-row: 2;
    flex-direction: column;
    gap: 2vh;
    padding: 2vh 0;
    width: 100%;
    position: relative;
  }
  
  .score-side {
    width: 100%;
    justify-content: center;
    position: relative;
  }
  
  .score-text {
    font-size: 22vh;
    line-height: 1;
  }
  
  #HomeBalls {
    grid-column: 1;
    grid-row: 4;
    flex-direction: column;
    justify-content: center;
    padding: 1vh 0;
    width: 100%;
  }
  
  #AwayBalls {
    grid-column: 1;
    grid-row: 5;
    flex-direction: column;
    justify-content: center;
    padding: 1vh 0;
    width: 100%;
  }
  
  #BottomFramesRow {
    grid-column: 1;
    grid-row: 7;
    gap: 2vw;
    row-gap: 1.5vh;
    padding: 1.5vh 2vw;
    min-height: auto;
  }
  
  .bottom-frame-badge {
    width: 7vh;
    height: 7vh;
    font-size: 4.5vh;
  }
  
  .balls-side {
    padding-top: 0;
    width: 100%;
    position: relative;
  }
  
  .balls-container {
    flex-direction: row;
    gap: 1.5vw;
    justify-content: center;
    width: 100%;
    overflow-x: auto;
    padding: 1vh 0;
  }
  
  .frames-history {
    flex-direction: row;
    max-width: 100%;
    overflow-x: auto;
    padding: 1vh 0;
    width: 100%;
    justify-content: center;
  }
  
  .team-column {
    width: 100%;
    margin-bottom: 1vh;
  }
  
  .frame-badge {
    min-width: 12vw;
    padding: 1vh 1.5vw;
    flex-shrink: 0;
  }
  
  .team-row {
    grid-column: 1;
    grid-row: 6;
    flex-direction: column;
    gap: 2vh;
    width: 100%;
    margin-top: 1vh; /* Add space between scores and team names on mobile */
  }
  
  .team-column {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5vh;
  }
  
  .team-name {
    font-size: 4vh;
    height: auto;
    min-height: 8vh;
    width: 100%;
  }
  
  .team-name img {
    max-height: 8vh;
    max-width: 80vw;
  }
  
  .ball-image {
    height: 5vh;
    width: 5vh;
    flex-shrink: 0;
  }
  
  #FrameInProgress {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    z-index: 100;
    min-width: 25vw;
    max-width: 30vw;
    padding: 2vh 3vw;
  }
  
  .frame-in-progress-number { font-size: 6vh; }
  .frame-in-progress-label { font-size: 2.2vh; }
  .frame-in-progress-spinner { font-size: 5vh; }
  
  #FullscreenBtn {
    top: 1vh;
    right: 1vh;
    padding: 1vh 1.5vh;
    font-size: 1.4vh;
    z-index: 1100;
  }
}

@media (max-width: 480px) {
  #ScoreboardLayout {
    padding: 1.5vh 2vw;
    width: 100%;
    max-width: 100vw;
  }
  
  #VenueCourtRow {
    font-size: 2vh;
    width: 100%;
  }
  
  .score-text {
    font-size: 18vh;
  }
  
  .team-name {
    font-size: 3.5vh;
    min-height: 7vh;
    width: 100%;
  }
  
  .team-name img {
    max-height: 7vh;
    max-width: 90vw;
  }
  
  .timeouts {
    font-size: 4vh;
    width: 100%;
  }
  
  .ball-image {
    height: 4vh;
    width: 4vh;
    flex-shrink: 0;
  }
  
  .frame-badge {
    min-width: 15vw;
    padding: 0.8vh 1.2vw;
    flex-shrink: 0;
  }
  
  .frame-badge-points {
    font-size: 2vh;
  }
  
  .frame-badge-number {
    font-size: 1vh;
  }
  
  .balls-container {
    gap: 1vw;
  }
  
  #BottomFramesRow {
    gap: 2.5vw;
    row-gap: 1.5vh;
    padding: 1.5vh 2vw;
  }
  
  .bottom-frame-badge {
    width: 5.5vh;
    height: 5.5vh;
    font-size: 3.5vh;
  }
  
  #FrameInProgress {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    z-index: 100;
    min-width: 30vw;
    max-width: 35vw;
    padding: 1.8vh 2.5vw;
  }
  
  .frame-in-progress-number { font-size: 5.5vh; }
  .frame-in-progress-label { font-size: 2vh; }
  .frame-in-progress-spinner { font-size: 4.5vh; }
  
  #BottomFramesRow {
    gap: 3vw;
    row-gap: 1.5vh;
    padding: 1.5vh 1.5vw;
  }
  
  .bottom-frame-badge {
    width: 5vh;
    height: 5vh;
    font-size: 3.2vh;
  }
}

/* Touch-friendly improvements for mobile */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
  #FullscreenBtn {
    padding: 1.5vh 2vh;
    font-size: 1.6vh;
    min-height: 44px; /* iOS touch target minimum */
    min-width: 44px;
  }
  
  .ball-image {
    cursor: pointer;
    margin: 0.5vh;
  }
  
  .frame-badge {
    margin: 0.5vh;
    cursor: default;
  }
}

/* Landscape orientation for mobile devices */
@media (max-height: 600px) and (orientation: landscape) {
  #ScoreboardLayout {
    grid-template-columns: 5vw 1fr 1fr 5vw;
    grid-template-rows: 8vh 6vh 25vh 8vh 5vh 12vh;
    row-gap: 1vh;
  }
  
  .score-text {
    font-size: 28vh;
  }
  
  .team-name {
    font-size: 4.5vh;
    height: 10vh;
  }
  
  .team-name img {
    max-height: 10vh;
  }
  
  .timeouts {
    font-size: 5vh;
  }
  
  .ball-image {
    height: 5vh;
    width: 5vh;
  }
  
  .bottom-frame-badge {
    width: 5vh;
    height: 5vh;
    font-size: 3.2vh;
  }
}

/* Ultra-wide screens (21:9 aspect ratio and wider) */
@media (min-aspect-ratio: 21/9) and (min-width: 1400px) {
  #ScoreboardLayout {
    grid-template-columns: 15vw 1fr 1fr 15vw;
    grid-template-rows: 4vh 9vh 36vh 2vh 10vh 18vh;
    column-gap: 3vw;
    row-gap: 2vh;
  }
  
  .score-text {
    font-size: 48vh;
  }
  
  .team-name {
    font-size: 6.5vh;
  }
  
  .ball-image {
    height: 10vh;
    width: 10vh;
  }
  
  .frame-badge {
    min-width: 3vw;
  }
  
  .bottom-frame-badge {
    width: 11vh;
    height: 11vh;
    font-size: 6.5vh;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .ball-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
  
  .team-name img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* ========================================
   STAT CELEBRATION OVERLAY STYLES
   ======================================== */

.stat-celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
}

.stat-celebration-overlay.hidden {
  display: none;
}

.stat-celebration-overlay.show {
  display: block !important;
  pointer-events: auto !important;
  animation: overlayFadeIn 0.3s ease-out forwards;
}

.stat-celebration-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
}

.stat-celebration-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 4rem 6rem;
  border-radius: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.stat-celebration-player-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.stat-celebration-player-avatar {
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.stat-celebration-player-name {
  font-size: 2.5rem;
  font-weight: 700;
  text-align: center;
}

.stat-celebration-icon {
  font-size: 12rem;
}

.stat-celebration-text {
  font-size: 4rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes statPopIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(-10deg);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15) rotate(5deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

@keyframes statMoveToHome {
  0% {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    top: 45%;
    left: 20%;
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 1;
  }
}

@keyframes statMoveToAway {
  0% {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    top: 45%;
    left: 80%;
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 1;
  }
}

.stat-celebration-content.pop-in {
  animation: statPopIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.stat-celebration-content.move-to-home {
  animation: statMoveToHome 0.8s ease-in-out forwards;
}

.stat-celebration-content.move-to-away {
  animation: statMoveToAway 0.8s ease-in-out forwards;
}

/* Stat-specific colors for celebration */
.stat-celebration-good-point {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: white;
}

.stat-celebration-bad-point {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.stat-celebration-hit {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.stat-celebration-miss {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  color: white;
}

.stat-celebration-foot-foul {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: white;
}

.stat-celebration-shot-clock-violation {
  background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
  color: white;
}

/* Stat Badges that replace balls */
.stat-badge {
  position: relative;
  width: var(--ball-size, 8vh);
  height: var(--ball-size, 8vh);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 3px solid rgba(255, 255, 255, 0.3);
  overflow: hidden;
}

.stat-badge-avatar {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.4;
}

.stat-badge-icon {
  position: relative;
  z-index: 1;
  font-size: 3.5vh;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
