body {
  font-family: 'sans-serif';
  background: linear-gradient(135deg, #000000, #000000);
  color: rgb(248, 246, 218);
  margin: 0;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  width: 100%; /* Take full width of viewport */
  max-width: 100%; /* Prevents stretching beyond viewport width */
  min-width: 320px; /* Minimum width for smaller devices */
  margin: 0; /* Remove default body margins */
  display: flex;
  flex-direction: column;
  align-items: center; /* Center content horizontally */
}

h1 {
  font-size: 2em; /* Reduced font size for smaller screens */
  text-shadow: 0 0 5px rgba(197, 0, 171, 0.948); /* Smaller glow */
  margin-top: 20px; /* Reduced margin */
  color: #f06292;
  text-align: center;
}

form {
  background: linear-gradient(to bottom, #560077a3, #0a2b63);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(2, 225, 246, 0.53);
  width: 100%; /* Make form responsive */
  max-width: 600px; /* Set a maximum width for larger screens */
  margin: 20px auto;
  text-align: center;
}

label {
  display: block;
  margin-bottom: 8px; /* Reduced margin */
  color: #d6e7ff;
  font-weight: bold;
}

input[type="file"] {
  border: 0px solid #448aff; /* Thinner border */
  background-color: #2b2d30;
  color: #a0d9ff;
  box-sizing: border-box;
}

button[type="submit"] {
  background: linear-gradient(to right, #ff577f, #ff807f);
  color: #1e2022;
  border: none;
  padding: 12px 15px; /* Reduced padding */
  cursor: pointer;
  font-weight: bold;
  width: 100%;
  box-shadow: 0 2px 4px rgba(56, 2, 127, 0.877); /* Reduced shadow */
  transition: transform 0.2s ease;
}

button[type="submit"]:hover {
  transform: translateY(-1px); /* Smaller lift */
}

#results {
  display: none;
  margin-top: 20px;
  background: linear-gradient(to bottom, #282c34, #1d2128);
  padding: 15px; /* Reduced padding */
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); /* Reduced shadow */
  width: 90%; /* Increased width */
  max-width: 450px;
  color: #37126b;
  text-align: center;
}

#results h2 {
  color: #ff577f;
}

#results p {
  margin-bottom: 8px; /* Reduced margin */
}

#results p.error {
  color: #ff4d4d;
}

body::before { /* Grid overlay - consider removing for mobile */
  display: none; /* Hide grid on smaller screens */
}


#average-score {
  margin-top: 15px;
  border: 1px solid #333;
  padding: 10px;
  background-color: #f0f0f0;
  text-align: center;
  border-radius: 8px;
}

#average-score h2 {
  color: #333;
  margin-bottom: 5px;
}

#average-score #average-value {
  font-weight: bold;
  font-size: 1.1em;
}

#average-score.high-similarity {
  background-color: #00ff00;
  border-color: #008000;
}

.score-box {
  margin-top: 15px;
  border: 1px solid #333;
  padding: 10px;
  background-color: #f0f0f0;
  text-align: center;
  border-radius: 8px;
}

.score-box h2 {
  color: #050000;
  margin-bottom: 5px;
}

.score-box > div { /* Target the inner div for consistent styling */
  font-weight: bold;
  font-size: 1.1em;
}

.score-box.high-similarity {
  background-color: #7a048c;
  border-color: #008000;
}

.image-container {
  display: flex;
  flex-wrap: wrap; /* Allows elements to wrap to next line on small screens */
  justify-content: center; /* Center items horizontally */
  width: 100%; /* Takes up full viewport width */
  max-width: 800px; /* Max width of the container */ /* Adjust this based on your preference */
}

.image-preview-container {
  flex: 1; /* Allows elements to take available space within the container */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 300px;
  padding: 10px;
  border: 0px solid #ddd;
  border-radius: 10px;
  background: rgba(89, 0, 128, 0.5);
  position: relative;
  flex: 1; /* Allow images to expand to fill available space */
  min-width: 0; /* Prevents minimum width constraints */
  margin: 10px; /* Add spacing between images */
  box-sizing: border-box; 
}

/* Loading animation */
.image-preview-container .loading-spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
}

/* Show loading spinner when flipping */
.image-preview-container.loading img {
  display: none;
}

.image-preview-container.loading .loading-spinner {
  display: block;
}

.image-preview-container img {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
  display: block;
}

/* Flip button styling */
.flip-button {
  background: linear-gradient(to right, #ff9800, #ffb74d);
  color: #fff;
  padding: 10px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 10px;
}

.flip-button:hover {
  background: #ff9800;
}

/* Media Queries for Smaller Screens */
@media (max-width: 768px) { /* Adjust breakpoint if needed */
  .image-container {
    flex-direction: column; /* Stack images vertically */
  }
  .image-preview-container {
    width: 100%;
  }

  form {
    max-width: 100%; /* Form takes full width on smaller screens */
  }
}