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

body {
  font-family: "Poppins", sans-serif;
  background: linear-gradient(135deg, #ff6b6b 0%, #4ecdc4 50%, #ffe66d 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  color: white;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.container {
  text-align: center;
  position: relative;
}

h1 {
  font-family: "Fredoka One", cursive;
  font-size: 4rem;
  margin-bottom: 0.5rem;
  text-shadow:
    3px 3px 0px #ff6b6b,
    6px 6px 0px rgba(0, 0, 0, 0.2);
  color: #ffe66d;
  letter-spacing: 2px;
  animation: bounce 2s ease-in-out infinite;
}

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

.instructions {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  font-weight: 600;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
  color: #fff;
}

.canvas-wrapper {
  position: relative;
  width: 640px;
  height: 480px;
  margin: 0 auto;
  border: 6px solid #fff;
  border-radius: 20px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.4),
    0 0 0 3px #ff6b6b,
    0 0 20px rgba(255, 107, 107, 0.5);
  overflow: hidden;
  transition: all 0.3s ease;
}

.canvas-wrapper:hover {
  transform: translateY(-5px);
  box-shadow:
    0 15px 50px rgba(0, 0, 0, 0.5),
    0 0 0 3px #ff6b6b,
    0 0 30px rgba(255, 107, 107, 0.7);
}

#webcam {
  display: none;
}

#gameCanvas {
  display: block;
  background: #000;
  border-radius: 14px;
}

#scoreDisplay {
  margin-top: 1.5rem;
  font-size: 2rem;
  font-weight: 700;
  font-family: "Fredoka One", cursive;
  color: #ffe66d;
  text-shadow:
    2px 2px 0px #ff6b6b,
    4px 4px 0px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.2);
  padding: 0.5rem 2rem;
  border-radius: 50px;
  display: inline-block;
  backdrop-filter: blur(10px);
}

.overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.98);
  padding: 3rem 2rem;
  border-radius: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 100;
  backdrop-filter: blur(20px);
  animation: overlayPop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes overlayPop {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.overlay.hidden {
  display: none;
}

.overlay h2 {
  font-family: "Fredoka One", cursive;
  font-size: 2.8rem;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

#overlayMessage {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#startButton {
  background: linear-gradient(135deg, #4ecdc4 0%, #44a3d5 100%);
  color: white;
  border: none;
  padding: 1.2rem 3rem;
  font-size: 1.4rem;
  font-family: "Poppins", sans-serif;
  font-weight: 700;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

#startButton::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s;
}

#startButton:hover::before {
  left: 100%;
}

#startButton:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(78, 205, 196, 0.6);
}

#startButton:active {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

#startButton:disabled {
  background: linear-gradient(135deg, #ccc 0%, #999 100%);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-content h2 {
  font-family: "Fredoka One", cursive;
  font-size: 2rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.loading-content p {
  font-family: "Poppins", sans-serif;
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Spinner animation */
.loader {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top: 5px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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