:root {
  --bg-color: #f4f7f6;
  --card-bg: #ffffff;
  --text-color: #333333;
  --text-muted: #666666;
  --primary-color: #6a11cb;
  --secondary-color: #2575fc;
  --btn-hover: #5a0eb0;
  --border-color: #e0e0e0;
}

[data-theme='dark'] {
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --text-color: #e0e0e0;
  --text-muted: #aaaaaa;
  --primary-color: #bb86fc;
  --secondary-color: #3700b3;
  --btn-hover: #9965f4;
  --border-color: #333;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
  line-height: 1.6;
}

.container {
  background-color: var(--card-bg);
  width: 100%;
  max-width: 650px;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  text-align: center;
  box-sizing: border-box;
  transition: all 0.5s ease;
}

/* Criminal Theme Overrides */
.container.criminal-theme {
  border: 3px solid #ff4d4d;
  box-shadow: 0 0 30px rgba(255, 77, 77, 0.2);
}

.criminal-theme h1 {
  background: linear-gradient(to right, #ff4d4d, #b30000);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.criminal-theme .main-btn {
  background: linear-gradient(to right, #ff4d4d, #b30000);
  box-shadow: 0 5px 15px rgba(255, 77, 77, 0.3);
}

.criminal-theme .image-upload-wrap {
  border-color: #ff4d4d;
}

.criminal-theme .drag-text h3 {
  color: #ff4d4d;
}

.criminal-theme .luck-item {
  border-left: 5px solid #ff4d4d;
}

.criminal-theme #result-title {
  color: #ff4d4d;
  font-weight: 900;
  text-transform: uppercase;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 15px;
}

.mode-selector {
  display: flex;
  gap: 10px;
}

.mode-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 8px 15px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  font-weight: 500;
}

.mode-btn.active {
  background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  color: white;
  border-color: transparent;
}

.mode-btn:hover:not(.active) {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

h1 {
  font-size: 1.8rem;
  margin: 0;
  background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.toggle-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.3s ease;
}

.toggle-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.upload-section {
  margin-bottom: 30px;
}

.image-upload-wrap {
  border: 2px dashed var(--border-color);
  position: relative;
  border-radius: 15px;
  padding: 40px 20px;
  transition: all 0.3s ease;
}

.image-upload-wrap:hover {
  background-color: rgba(0,0,0,0.02);
  border-color: var(--primary-color);
}

.file-upload-input {
  position: absolute;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  outline: none;
  opacity: 0;
  cursor: pointer;
  top: 0;
  left: 0;
}

.drag-text h3 {
  font-weight: 500;
  text-transform: uppercase;
  color: var(--primary-color);
  margin-bottom: 10px;
}

.drag-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.file-upload-content {
  display: none;
  text-align: center;
}

.file-upload-image {
  max-width: 100%;
  max-height: 400px;
  margin: auto;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.image-title-wrap {
  margin-top: 15px;
}

.remove-image {
  background: #ff5f5f;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
}

.main-btn {
  width: 100%;
  padding: 15px;
  font-size: 1.1rem;
  background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  transition: transform 0.2s;
}

.main-btn:hover {
  transform: translateY(-2px);
}

.loading {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

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

.hidden {
  display: none !important;
}

/* Result Section Updated */
.result-container {
  margin-top: 30px;
  padding: 30px;
  background-color: rgba(0,0,0,0.03);
  border-radius: 20px;
  text-align: left;
}

#result-title {
  color: var(--primary-color);
  font-size: 1.6rem;
  margin-bottom: 15px;
  text-align: center;
}

.main-desc {
  text-align: center;
  font-size: 1.05rem;
  margin-bottom: 30px;
  color: var(--text-color);
  font-weight: 500;
}

.luck-details-grid {
  display: grid;
  gap: 25px;
  margin-bottom: 30px;
}

.luck-item {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.luck-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.luck-label {
  font-weight: bold;
  font-size: 1rem;
}

.luck-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.bar-container {
  width: 100px;
  background-color: #e0e0e0;
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
}

.bar {
  height: 100%;
  background: linear-gradient(to right, var(--secondary-color), var(--primary-color));
  width: 0%;
  transition: width 1s ease-out;
}

.retry-btn {
  display: block;
  width: 100%;
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  margin-top: 10px;
}

/* Info & Footer */
.info-section {
  text-align: left;
  margin-top: 50px;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.footer {
  margin-top: 40px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.divider {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 30px 0;
}

@media (max-width: 480px) {
  .container {
    padding: 20px;
  }
  .luck-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .bar-container {
    width: 100%;
  }
}
