* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f5f7fa 50%, #ffffff 100%);
  background-size: 400% 400%;
  animation: gradientShift 15s ease infinite;
  color: #2c3e50;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  text-align: center;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Animated background gradient */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Floating particles effect */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 40% 20%, rgba(102, 126, 234, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  animation: float 20s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

h2 {
  margin: 20px 0 30px 0;
  font-size: 36px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  position: relative;
  animation: fadeInDown 0.8s ease-out;
  text-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
}

h2::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, transparent, #667eea, transparent);
  border-radius: 2px;
  animation: expandLine 1s ease-out 0.5s both;
}

@keyframes expandLine {
  from { width: 0; }
  to { width: 60px; }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.container {
  max-width: 600px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 28px;
  padding: 45px 35px;
  box-shadow: 
    0 8px 32px rgba(102, 126, 234, 0.15),
    0 2px 8px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.8s ease-out;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.container:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 40px rgba(102, 126, 234, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

canvas {
  width: 100%;
  max-width: 420px;
  border-radius: 20px;
  margin: 25px auto;
  display: block;
  box-shadow: 
    0 12px 32px rgba(102, 126, 234, 0.2),
    0 4px 16px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.5);
  transition: all 0.3s ease;
  animation: fadeInScale 1s ease-out 0.3s both;
  position: relative;
  overflow: hidden;
}

canvas::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
  animation: shine 3s infinite;
}

@keyframes shine {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

canvas:hover {
  transform: scale(1.02);
  box-shadow: 
    0 16px 40px rgba(102, 126, 234, 0.25),
    0 6px 20px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

#result {
  font-size: 30px;
  font-weight: 700;
  margin: 30px 0;
  min-height: 50px;
  color: #1a1a1a;
  padding: 20px 25px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 16px;
  border: 2px solid rgba(232, 232, 232, 0.8);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  animation: pulse 2s ease-in-out infinite;
}

#result::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transition: left 0.5s;
}

#result.updated::before {
  left: 100%;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 
      0 4px 16px rgba(0, 0, 0, 0.08),
      inset 0 1px 0 rgba(255, 255, 255, 0.8);
  }
  50% {
    box-shadow: 
      0 6px 20px rgba(102, 126, 234, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.8);
  }
}

#result.mask-detected {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
  border-color: rgba(46, 125, 50, 0.3);
  color: #2e7d32;
  animation: successPulse 0.6s ease-out;
}

#result.nomask-detected {
  background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
  border-color: rgba(198, 40, 40, 0.3);
  color: #c62828;
  animation: alertPulse 0.6s ease-out;
}

#result.loading {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border-color: rgba(230, 81, 0, 0.3);
  color: #e65100;
}

@keyframes successPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes alertPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

#predictions {
  font-size: 17px;
  margin-top: 25px;
  line-height: 2.2;
  min-height: 120px;
  color: #4a5568;
  padding: 25px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 16px;
  border: 2px solid rgba(232, 232, 232, 0.8);
  text-align: left;
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.3s ease;
  animation: fadeIn 1s ease-out 0.5s both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#predictions:hover {
  box-shadow: 
    0 6px 20px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: translateY(-2px);
}

#predictions br {
  margin-bottom: 10px;
}

#predictions span {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.3s ease;
  margin-right: 5px;
}

#predictions span:hover {
  background: rgba(102, 126, 234, 0.1);
  transform: translateX(5px);
}

button {
  font-size: 16px;
  font-weight: 600;
  padding: 14px 36px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  cursor: pointer;
  margin: 10px 5px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 14px rgba(102, 126, 234, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

button:hover::before {
  width: 300px;
  height: 300px;
}

button:hover {
  transform: translateY(-3px);
  box-shadow: 
    0 8px 20px rgba(102, 126, 234, 0.5),
    0 4px 8px rgba(0, 0, 0, 0.15);
}

button:active {
  transform: translateY(-1px);
  box-shadow: 
    0 4px 12px rgba(102, 126, 234, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.1);
}

input {
  font-size: 15px;
  padding: 16px 20px;
  border-radius: 14px;
  border: 2px solid rgba(232, 232, 232, 0.8);
  background: rgba(255, 255, 255, 0.9);
  color: #1a1a1a;
  width: 100%;
  max-width: 100%;
  margin: 10px 0;
  transition: all 0.3s ease;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 
    0 0 0 4px rgba(102, 126, 234, 0.15),
    0 4px 12px rgba(102, 126, 234, 0.2);
  background: #ffffff;
  transform: translateY(-2px);
}

input::placeholder {
  color: #a0a0a0;
}

.url-container {
  margin: 30px 0;
  text-align: left;
  display: none;
}

.url-container > div:first-child {
  font-size: 14px;
  font-weight: 500;
  color: #4a5568;
  margin-bottom: 12px;
}

#webcam-container {
  margin: 25px 0;
  position: relative;
}

/* Loading spinner */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(102, 126, 234, 0.3);
  border-radius: 50%;
  border-top-color: #667eea;
  animation: spin 1s ease-in-out infinite;
  margin-right: 10px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
  .container {
    padding: 30px 20px;
    border-radius: 24px;
    margin: 10px;
  }
  
  h2 {
    font-size: 28px;
  }
  
  #result {
    font-size: 24px;
    padding: 16px 20px;
  }
  
  canvas {
    max-width: 100%;
  }
}

