body {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #000;
  font-family: "IRANSans", "Arial", sans-serif;
  overflow: hidden;
}

/* استایل‌های فرم تنظیمات گوشواره */
.setup-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 5000;
  padding: 20px;
  box-sizing: border-box;
}

.setup-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 30px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  max-height: 90vh;
  overflow-y: auto;
}

.setup-container h2 {
  text-align: center;
  margin: 0 0 25px 0;
  color: #2c3e50;
  font-size: 24px;
  font-weight: 600;
}

.setup-item {
  margin-bottom: 25px;
}

.setup-label {
  display: block;
  margin-bottom: 10px;
  color: #2c3e50;
  font-weight: 600;
  font-size: 14px;
}

/* استایل اپلود فایل */
.file-input {
  width: auto;
  padding: 12px;
  border: 2px dashed #667eea;
  border-radius: 10px;
  background: rgba(102, 126, 234, 0.1);
  color: #2c3e50;
  font-family: "IRANSans", Arial, sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.file-input:hover {
  border-color: #764ba2;
  background: rgba(118, 75, 162, 0.1);
}

.file-input:focus {
  outline: none;
  border-color: #764ba2;
  box-shadow: 0 0 10px rgba(118, 75, 162, 0.3);
}

/* پیش‌نمایش عکس */
.file-preview {
  position: relative;
  margin-top: 15px;
  border-radius: 10px;
  overflow: hidden;
  background: #f8f9fa;
  border: 2px solid #e9ecef;
}

.file-preview img {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background: white;
}

.remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(231, 76, 60, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.remove-btn:hover {
  background: rgba(231, 76, 60, 1);
  transform: scale(1.1);
}

/* حالت تنظیم ابعاد */
.dimension-mode {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.radio-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(102, 126, 234, 0.1);
  transition: all 0.3s ease;
  font-size: 14px;
  color: #2c3e50;
}

.radio-label:hover {
  background: rgba(102, 126, 234, 0.2);
}

.radio-label input[type="radio"] {
  margin-left: 8px;
  accent-color: #667eea;
}

.radio-label input[type="radio"]:checked + span {
  font-weight: 600;
  color: #667eea;
}

/* کانتینر ابعاد */
.dimensions-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.dimension-input {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.number-input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  font-size: 14px;
  font-family: "IRANSans", Arial, sans-serif;
  color: #2c3e50;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.number-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.number-input:disabled {
  background: #f8f9fa;
  color: #6c757d;
  cursor: not-allowed;
}

.auto-note {
  position: absolute;
  bottom: -18px;
  left: 0;
  font-size: 11px;
  color: #6c757d;
  font-style: italic;
}

/* دکمه شروع */
.start-button {
  width: 100%;
  padding: 15px;
  background: linear-gradient(145deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 15px;
  font-size: 16px;
  font-weight: 600;
  font-family: "IRANSans", Arial, sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.start-button:hover:not(:disabled) {
  background: linear-gradient(145deg, #764ba2, #667eea);
  box-shadow: 0 12px 25px rgba(102, 126, 234, 0.4);
  transform: translateY(-2px);
}

.start-button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 6px 15px rgba(102, 126, 234, 0.3);
}

.start-button:disabled {
  background: #6c757d;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* دکمه بازگشت */
.back-button {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 12px 20px;
  font-size: 14px;
  font-family: "IRANSans", Arial, sans-serif;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.back-button:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.container {
  position: relative;
  width: 100%;
  height: 100vh;
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

video {
  display: none;
}

canvas {
  display: block;
  object-fit: contain;
  background-color: #000;
  transform: scaleX(-1);
}

/* پیام‌ها - رنگ بنفش گوشواره */
#message-box {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.95),
    rgba(118, 75, 162, 0.95)
  );
  backdrop-filter: blur(10px);
  color: white;
  padding: 12px 20px;
  border-radius: 25px;
  z-index: 20;
  display: none;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  max-width: 300px;
  transition: all 0.3s ease;
}

/* کنترل‌ها - بهبود responsive */
#controls-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: linear-gradient(145deg, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.75));
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 280px;
  max-width: calc(100vw - 40px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

#controls-container:hover {
  background: linear-gradient(145deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.8));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.label {
  color: white;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
}

.value {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0.8)
  );
  color: #2c3e50;
  font-size: 14px;
  font-weight: bold;
  padding: 8px 12px;
  border-radius: 15px;
  min-width: 30px;
  text-align: center;
  align-self: center;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.2),
    0 1px 0 rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.9);
  text-shadow: none;
  transition: all 0.2s ease;
}

/* استایل جدید اسلایدرها - رنگ بنفش گوشواره */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 12px;
  border-radius: 25px;
  background: linear-gradient(
    to right,
    rgba(102, 126, 234, 0.3) 0%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(118, 75, 162, 0.3) 100%
  );
  outline: none;
  width: 100%;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.2);
  position: relative;
  transition: all 0.3s ease;
  touch-action: manipulation;
  cursor: pointer;
}

input[type="range"]:hover {
  background: linear-gradient(
    to right,
    rgba(102, 126, 234, 0.4) 0%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(118, 75, 162, 0.4) 100%
  );
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(255, 255, 255, 0.2), 0 0 10px rgba(102, 126, 234, 0.3);
}

/* Webkit Thumb - بهبود responsive */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.8), inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  border: 2px solid rgba(102, 126, 234, 0.6);
  transition: all 0.2s ease;
  position: relative;
  touch-action: manipulation;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: linear-gradient(145deg, #ffffff, #e8e8e8);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(0, 0, 0, 0.15),
    0 0 15px rgba(102, 126, 234, 0.4);
  transform: scale(1.1);
  border-color: rgba(102, 126, 234, 0.8);
}

input[type="range"]::-webkit-slider-thumb:active {
  background: linear-gradient(145deg, #f8f8f8, #e0e0e0);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  transform: scale(0.95);
}

/* Mozilla Thumb - بهبود responsive */
input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  cursor: pointer;
  border: 2px solid rgba(102, 126, 234, 0.6);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
  background: linear-gradient(145deg, #ffffff, #e8e8e8);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 0 15px rgba(102, 126, 234, 0.4);
  transform: scale(1.1);
}

/* Track styling for different browsers */
input[type="range"]::-webkit-slider-runnable-track {
  height: 12px;
  border-radius: 25px;
  background: inherit;
}

input[type="range"]::-moz-range-track {
  height: 12px;
  border-radius: 25px;
  background: inherit;
  border: none;
}

/* دکمه‌های کنترل - رنگ بنفش گوشواره */
.control-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.control-btn {
  background: linear-gradient(
    145deg,
    rgba(102, 126, 234, 0.3),
    rgba(118, 75, 162, 0.2)
  );
  border: 1px solid rgba(102, 126, 234, 0.4);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.control-btn:hover {
  background: linear-gradient(
    145deg,
    rgba(102, 126, 234, 0.5),
    rgba(118, 75, 162, 0.3)
  );
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 15px rgba(102, 126, 234, 0.3);
  transform: translateY(-2px);
  border-color: rgba(102, 126, 234, 0.6);
}

.control-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Splash Screen - رنگ بنفش گوشواره */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  transition: opacity 0.5s ease;
}

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

.splash-logo {
  margin-bottom: 30px;
}

.logo-animation {
  width: 80px;
  height: 80px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

.logo-animation.earrings-theme {
  border-top: 4px solid #ffffff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
  /* افکت درخشش مخصوص گوشواره */
  animation: spin 1s linear infinite, shimmer 2s ease-in-out infinite;
}

.splash-content h1 {
  font-size: 28px;
  margin: 20px 0 10px 0;
  font-weight: 300;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.splash-content p {
  font-size: 16px;
  opacity: 0.8;
  margin-bottom: 0;
}

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

@keyframes shimmer {
  0% {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.5);
  }
  100% {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
  }
}

/* Error Fallback - رنگ بنفش */
#error-fallback {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10001;
}

.error-content {
  text-align: center;
  color: white;
  max-width: 400px;
  padding: 40px;
}

.error-content h2 {
  font-size: 32px;
  margin-bottom: 20px;
  font-weight: 300;
}

.error-content p {
  font-size: 18px;
  margin-bottom: 30px;
  opacity: 0.9;
}

.retry-button {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid white;
  color: white;
  padding: 12px 30px;
  border-radius: 25px;
  font-size: 16px;
  font-family: "IRANSans", Arial, sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
}

.retry-button:hover {
  background: white;
  color: #667eea;
}

/* تنظیمات رسپانسیو */
@media (max-width: 768px) {
  .setup-container {
    margin: 10px;
    padding: 20px;
    max-height: calc(100vh - 40px);
  }

  .setup-container h2 {
    font-size: 20px;
  }

  .dimensions-container {
    flex-direction: column;
  }

  .dimension-input {
    min-width: auto;
  }

  .back-button {
    top: 10px;
    right: 10px;
    padding: 10px 16px;
    font-size: 12px;
  }

  #controls-container {
    position: fixed;
    bottom: 10px;
    right: 5px;
    left: 5px;
    width: auto;
    max-width: none;
    padding: 10px;
    gap: 10px;
    border-radius: 12px;
    transform: scale(0.85);
    transform-origin: center bottom;
  }

  .control-item {
    gap: 6px;
  }

  .label {
    font-size: 10px;
    font-weight: 500;
  }

  .value {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 10px;
    min-width: 20px;
  }

  input[type="range"] {
    height: 10px;
    border-radius: 15px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
  }

  .control-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  canvas {
    max-height: 100vh;
    max-width: 100vw;
  }

  #message-box {
    top: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    max-width: none;
    font-size: 12px;
    padding: 8px 12px;
  }
}

/* موبایل‌های خیلی کوچک */
@media (max-width: 480px) {
  .setup-container {
    padding: 15px;
  }

  .dimension-mode {
    flex-direction: column;
    gap: 10px;
  }

  #controls-container {
    bottom: 5px;
    padding: 8px;
    gap: 8px;
    transform: scale(0.75);
  }

  .label {
    font-size: 9px;
  }

  .value {
    font-size: 10px;
    padding: 3px 6px;
  }

  input[type="range"] {
    height: 8px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }

  .control-btn {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .splash-content h1 {
    font-size: 20px;
  }

  .splash-content p {
    font-size: 13px;
  }

  .logo-animation {
    width: 50px;
    height: 50px;
  }
}

/* بهبود landscape در موبایل */
@media (max-width: 768px) and (orientation: landscape) {
  .setup-container {
    max-height: calc(100vh - 20px);
    padding: 15px;
  }

  #controls-container {
    bottom: 5px;
    padding: 6px;
    gap: 6px;
    transform: scale(0.65);
  }

  .label {
    font-size: 8px;
  }

  .value {
    padding: 2px 4px;
    font-size: 9px;
  }

  .control-btn {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  input[type="range"] {
    height: 6px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
  }
}

/* بهبود برای تبلت */
@media (min-width: 769px) and (max-width: 1024px) {
  .setup-container {
    max-width: 600px;
  }

  #controls-container {
    bottom: 40px;
    right: 15px;
    width: 220px;
    padding: 16px;
    gap: 16px;
  }

  .label {
    font-size: 12px;
  }

  .value {
    font-size: 13px;
    padding: 6px 10px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }

  .control-btn {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }
}

/* موبایل‌های بزرگ */
@media (min-width: 481px) and (max-width: 768px) {
  #controls-container {
    transform: scale(0.8);
  }
}

/* بهبود برای صفحه نمایش‌های بسیار کوچک */
@media (max-width: 360px) {
  #controls-container {
    transform: scale(0.7);
    bottom: 3px;
  }

  .label {
    font-size: 8px;
  }

  .value {
    font-size: 9px;
    padding: 2px 4px;
  }
}
