/* Modal Styles - Quiz Modal and Setup Section */

/* Winner Modal - Epic Celebration */
#winnerOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10020;
  padding: 20px;
  box-sizing: border-box;
  overflow: hidden;
}

.winner-content {
  background: linear-gradient(135deg, #a587b6 0%, #316d83 100%);
  color: #2d3559;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-radius: 20px;
  padding: 20px 15px 15px 15px;
  border: 2px solid #e0cfff;
  box-shadow: 0 16px 48px rgba(44, 62, 80, 0.13),
    0 4px 24px rgba(255, 255, 255, 0.1) inset,
    0 0 32px rgba(173, 216, 230, 0.13);
  text-align: center;
  max-width: 1200px;
  width: 100%;
  max-height: calc(100vh - 40px);
  height: 100%;
  overflow: hidden;
  position: relative;
  transform-style: preserve-3d;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.winner-trophy {
  font-size: 2.5em;
  margin-bottom: 10px;
  animation: trophySpectacular 2s ease-in-out;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4))
    drop-shadow(0 0 30px rgba(255, 215, 0, 0.6));
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.winner-trophy::before {
  content: "✨";
  position: absolute;
  top: -15px;
  left: -30px;
  font-size: 0.3em;
}

.winner-trophy::after {
  content: "🎉";
  position: absolute;
  top: -15px;
  right: -30px;
  font-size: 0.3em;
}

.winner-title {
  font-family: "Concert One", Arial, sans-serif;
  font-size: clamp(1.8em, 5vw, 3.5em);
  font-weight: bold;
  background: linear-gradient(
    45deg,
    #ff006e,
    #8338ec,
    #3a86ff,
    #06ffa5,
    #ffbe0b
  );
  background-size: 400% 400%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbowText 3s ease-in-out, titleBounce 1s ease-out 0.5s,
    titleShine 4s ease-in-out 2s;
  margin: 10px 0;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
  letter-spacing: 0.05em;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.winner-message-text {
  font-family: "Concert One", Arial, sans-serif;
  font-size: clamp(1em, 2.5vw, 1.5em);
  color: #fff;
  margin: 10px 0;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 255, 255, 0.3);
  line-height: 1.4;
  animation: textGlow 2s ease-in-out alternate;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.winner-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 15px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.winner-btn {
  width: 60px;
  height: 60px;
  padding: 0;
  font-size: 1.8em;
  font-family: "Concert One", Arial, sans-serif;
  font-weight: bold;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  min-width: 60px;
  position: relative;
  overflow: hidden;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 1;
  box-sizing: border-box;
}

.winner-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  transition: left 0.6s ease;
}

.winner-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transition: all 0.4s ease;
  transform: translate(-50%, -50%);
  z-index: -1;
}

.winner-btn:hover::before {
  left: 100%;
}

.winner-btn:hover::after {
  width: 300px;
  height: 300px;
}

.winner-btn:hover {
  transform: translateY(-3px) scale(1.1);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.winner-btn.home-btn {
  background: linear-gradient(135deg, #ff006e 0%, #8338ec 100%);
  color: #fff;
  border: 3px solid rgba(255, 255, 255, 0.4);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  box-shadow: 0 8px 20px rgba(255, 0, 110, 0.3);
}

.winner-btn.home-btn::before {
  content: "🏠";
  font-size: 1em;
}

.winner-btn.home-btn:hover {
  background: linear-gradient(135deg, #8338ec 0%, #3a86ff 100%);
  box-shadow: 0 15px 30px rgba(131, 56, 236, 0.4);
}

.winner-btn.restart-btn {
  background: linear-gradient(135deg, #06ffa5 0%, #3a86ff 100%);
  color: #fff;
  border: 3px solid rgba(255, 255, 255, 0.4);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  box-shadow: 0 8px 20px rgba(6, 255, 165, 0.3);
}

.winner-btn.restart-btn::before {
  content: "🔄";
  font-size: 1em;
}

.winner-btn.restart-btn:hover {
  background: linear-gradient(135deg, #3a86ff 0%, #ffbe0b 100%);
  box-shadow: 0 15px 30px rgba(58, 134, 255, 0.4);
}

/* Confetti and Celebration Effects */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.confetti {
  position: absolute;
  width: 20px;
  height: 20px;
  background: #f093fb;
  animation: confettiFall 4s linear;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
  opacity: 0.9;
}

.confetti:nth-child(1) {
  left: 10%;
  animation-delay: 0s;
  background: #667eea;
  width: 16px;
  height: 16px;
  border-radius: 0;
  transform: rotate(45deg);
}

.confetti:nth-child(2) {
  left: 20%;
  animation-delay: 0.2s;
  background: #f093fb;
  width: 24px;
  height: 12px;
  border-radius: 0;
}

.confetti:nth-child(3) {
  left: 30%;
  animation-delay: 0.4s;
  background: #ffd700;
  width: 12px;
  height: 24px;
  border-radius: 0;
}

.confetti:nth-child(4) {
  left: 40%;
  animation-delay: 0.6s;
  background: #ff6b6b;
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.confetti:nth-child(5) {
  left: 50%;
  animation-delay: 0.8s;
  background: #4ecdc4;
  width: 16px;
  height: 28px;
  border-radius: 0;
}

.confetti:nth-child(6) {
  left: 60%;
  animation-delay: 1s;
  background: #45b7d1;
  width: 24px;
  height: 16px;
  border-radius: 0;
  transform: rotate(45deg);
}

.confetti:nth-child(7) {
  left: 70%;
  animation-delay: 1.2s;
  background: #96ceb4;
  width: 12px;
  height: 20px;
  border-radius: 0;
}

.confetti:nth-child(8) {
  left: 80%;
  animation-delay: 1.4s;
  background: #ffeaa7;
  width: 20px;
  height: 24px;
  border-radius: 0;
}

.confetti:nth-child(9) {
  left: 90%;
  animation-delay: 1.6s;
  background: #fd79a8;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.confetti:nth-child(10) {
  left: 15%;
  animation-delay: 1.8s;
  background: #6c5ce7;
  width: 24px;
  height: 12px;
  border-radius: 0;
  transform: rotate(45deg);
}

.confetti:nth-child(11) {
  left: 25%;
  animation-delay: 2s;
  background: #e17055;
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.confetti:nth-child(12) {
  left: 35%;
  animation-delay: 2.2s;
  background: #00b894;
  width: 14px;
  height: 26px;
  border-radius: 0;
}

.confetti:nth-child(13) {
  left: 55%;
  animation-delay: 2.4s;
  background: #fdcb6e;
  width: 22px;
  height: 14px;
  border-radius: 0;
}

.confetti:nth-child(14) {
  left: 75%;
  animation-delay: 2.6s;
  background: #e84393;
  width: 16px;
  height: 22px;
  border-radius: 0;
  transform: rotate(45deg);
}

.confetti:nth-child(15) {
  left: 85%;
  animation-delay: 2.8s;
  background: #00cec9;
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.celebration-sparks {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #ffd700;
  animation: sparkBurst 1.5s ease-out;
}

.celebration-sparks:nth-child(1) {
  animation-delay: 0s;
  background: #ff6b6b;
}

.celebration-sparks:nth-child(2) {
  animation-delay: 0.2s;
  background: #4ecdc4;
}

.celebration-sparks:nth-child(3) {
  animation-delay: 0.4s;
  background: #f093fb;
}

.celebration-sparks:nth-child(4) {
  animation-delay: 0.6s;
  background: #667eea;
}

.celebration-sparks:nth-child(5) {
  animation-delay: 0.8s;
  background: #ffd700;
}

.celebration-balloons {
  position: absolute;
  font-size: 2.5em;
  animation: balloonFloat 4s ease-in-out;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.celebration-balloons:nth-child(1) {
  top: 20%;
  left: 5%;
  animation-delay: 0s;
}

.celebration-balloons:nth-child(2) {
  top: 30%;
  right: 8%;
  animation-delay: 1s;
}

.celebration-balloons:nth-child(3) {
  top: 60%;
  left: 3%;
  animation-delay: 2s;
}

.celebration-balloons:nth-child(4) {
  top: 70%;
  right: 5%;
  animation-delay: 3s;
}

.fireworks {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  animation: fireworkBurst 2s ease-out;
}

.fireworks:nth-child(1) {
  top: 20%;
  left: 20%;
  background: #ff6b6b;
  animation-delay: 0.5s;
}

.fireworks:nth-child(2) {
  top: 30%;
  left: 80%;
  background: #4ecdc4;
  animation-delay: 1s;
}

.fireworks:nth-child(3) {
  top: 70%;
  left: 15%;
  background: #ffd700;
  animation-delay: 1.5s;
}

.fireworks:nth-child(4) {
  top: 60%;
  left: 85%;
  background: #f093fb;
  animation-delay: 2s;
}

/* All animation keyframes moved to flipquiz_animations.css to avoid duplicates */
/* Setup, winner, celebration, and effect animations are now centralized */

#remoteQrContainer {
  position: fixed !important;
  right: 40px !important;
  bottom: 100px !important;
  z-index: 12001 !important;
  display: none; /* Hidden by default, toggled by button */
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px;
  box-shadow: 0 8px 32px 0 rgba(25, 158, 106, 0.18), 0 2px 8px #0002;
  padding: 22px 22px 14px 22px;
  min-width: 200px;
  max-width: 260px;
  border: 2.5px solid #199e6a;
  transition: box-shadow 0.2s, border 0.2s, background 0.2s;
  overflow: visible;
}
#remoteQrContainer.active,
#remoteQrContainer:focus-within {
  box-shadow: 0 0 0 4px #199e6a33, 0 8px 32px 0 rgba(25, 158, 106, 0.18),
    0 2px 8px #0002;
  border-color: #199e6a;
}
#remoteQrContainer > #remoteQr {
  width: 150px !important;
  height: 150px !important;
  min-width: 150px !important;
  min-height: 150px !important;
  max-width: 150px !important;
  max-height: 150px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px #199e6a22;
  margin-bottom: 12px;
  padding: 8px;
}
#remoteQrContainer > #remoteQr canvas {
  width: 134px !important;
  height: 134px !important;
  min-width: 134px !important;
  min-height: 134px !important;
  max-width: 134px !important;
  max-height: 134px !important;
  display: block;
  margin: 0 auto;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 6px #0001;
}
#remoteQrContainer > div {
  text-align: center;
  width: 100%;
}
#remoteQrContainer > div:nth-child(2) {
  margin-top: 2px;
  font-size: 1.18em;
  color: #199e6a;
  font-weight: bold;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 6px #fff, 0 1px 2px #199e6a22;
  margin-bottom: 2px;
}
#remoteQrContainer > div:nth-child(3) {
  font-size: 0.98em;
  color: #199e6a99;
  margin-bottom: 0;
  text-shadow: 0 1px 6px #fff, 0 1px 2px #199e6a22;
}

/* Enhanced Score Display */
.winner-score-display {
  margin: 30px 0;
  padding: 30px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.final-scores-container {
  max-width: 900px;
  margin: 0 auto;
  font-size: 1.3em;
}
.final-scores-title {
  font-size: 1.3em;
  font-weight: bold;
  margin-bottom: 12px;
  color: #2d3559;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.scores-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
}

.team-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.3s ease;
}

.team-score-row.winner-team {
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.3),
    rgba(255, 193, 7, 0.2)
  );
  border: 2px solid rgba(255, 215, 0, 0.5);
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.2);
  transform: scale(1.02);
}

.team-rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
}

.position-emoji {
  font-size: 1.5em;
  margin-bottom: 2px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.position-text {
  font-size: 0.8em;
  font-weight: bold;
  color: #2d3559;
  opacity: 0.8;
}

.team-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.team-name-final {
  font-size: 1em;
  font-weight: bold;
  color: #2d3559;
  text-align: left;
}

.score-bar-container {
  position: relative;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  height: 25px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.score-bar {
  height: 100%;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  border-radius: 8px;
  transition: width 1s ease-out;
  position: relative;
}

.winner-team .score-bar {
  background: linear-gradient(90deg, #ffd700 0%, #ffed4e 100%);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
  animation: scoreBarGlow 2s ease-in-out;
}

.score-value {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: bold;
  color: #2d3559;
  font-size: 0.9em;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.game-stats {
  display: flex;
  justify-content: space-around;
  padding: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 0.9em;
  color: #2d3559;
  opacity: 0.8;
}

.stat-value {
  font-size: 1.3em;
  font-weight: bold;
  color: #2d3559;
}

.score-error {
  padding: 20px;
  color: #e74c3c;
  font-weight: bold;
  text-align: center;
}

/* Animations */
@keyframes scoreBarGlow {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
  }
  50% {
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
  }
}

/* Ensure no overflow outside viewport */
#winnerOverlay * {
  box-sizing: border-box;
}

#winnerOverlay .winner-content {
  /* Prevent any element from going outside the modal */
  contain: layout style;
}

/* Prevent body scrolling when winner modal is open */
body.winner-modal-open {
  overflow: hidden;
  height: 100vh;
}

/* Setup Floating Elements */
.setup-floating-elements {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.setup-float-element {
  position: absolute;
  font-size: 2.5em;
  opacity: 0.6;
  animation: floatAround 10s ease-in-out;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  will-change: transform;
}

.setup-float-element:nth-child(1) {
  top: 15%;
  left: 8%;
  animation-delay: 0s;
}

.setup-float-element:nth-child(2) {
  top: 25%;
  right: 12%;
  animation-delay: 2.5s;
}

.setup-float-element:nth-child(3) {
  bottom: 20%;
  left: 10%;
  animation-delay: 5s;
}

.setup-float-element:nth-child(4) {
  bottom: 30%;
  right: 15%;
  animation-delay: 7.5s;
}
