/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 32px;
}
header h1 {
  font-size: 28px;
  color: #1a1a2e;
  margin-bottom: 16px;
}

/* Step Indicator */
#step-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.step {
  padding: 6px 16px;
  border-radius: 20px;
  background: #e0e0e0;
  font-size: 14px;
  font-weight: 500;
  color: #888;
  transition: all .25s;
}
.step.active {
  background: #4361ee;
  color: #fff;
}
.step.done {
  background: #2ec4b6;
  color: #fff;
}
.step-arrow {
  color: #ccc;
  font-size: 14px;
}

/* Panels */
.panel {
  display: none;
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.panel.active { display: block; }
.panel h2 { font-size: 20px; margin-bottom: 16px; color: #1a1a2e; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed #ccc;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: #4361ee;
  background: #f5f7ff;
}
.upload-hint { color: #999; font-size: 16px; }
.upload-status { margin-top: 12px; font-size: 14px; color: #666; }

/* Progress Bar */
.progress-bar {
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  margin-top: 16px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #4361ee, #7209b7);
  border-radius: 3px;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}
@keyframes progress-indeterminate {
  0% { width: 0; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0; margin-left: 100%; }
}

/* Summary */
.summary {
  margin-top: 16px;
  padding: 12px 16px;
  background: #e8f5e9;
  border-radius: 8px;
  font-size: 14px;
}

/* Image Grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.image-card {
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  background: #fafafa;
}
.image-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.image-card.replaced { border-color: #2ec4b6; }
.image-card .thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 16px 16px;
}
.image-card .info {
  padding: 6px 8px;
  font-size: 11px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.image-card .badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  background: #2ec4b6;
  color: #fff;
  margin-left: 4px;
}

/* Buttons */
.btn {
  padding: 8px 20px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  background: #fff;
  color: #333;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f5f5f5; }
.btn-primary { background: #4361ee; color: #fff; border-color: #4361ee; }
.btn-primary:hover { background: #3a56d4; }
.btn-secondary { background: #7209b7; color: #fff; border-color: #7209b7; }
.btn-secondary:hover { background: #5f0799; }
.btn-large { padding: 12px 32px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-content h3 { margin-bottom: 12px; }
.modal-preview { text-align: center; margin-bottom: 16px; }
.modal-preview img { max-width: 100%; max-height: 300px; border-radius: 8px; }
.modal-path { font-size: 12px; color: #999; margin-bottom: 8px; word-break: break-all; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
#modal-status { margin-top: 10px; font-size: 13px; text-align: center; color: #2ec4b6; }

/* Links */
.links-section { margin-bottom: 20px; }
.links-section h3 { font-size: 15px; margin-bottom: 8px; }
.link-found-item { font-size: 13px; color: #666; margin: 4px 0; word-break: break-all; }
.link-found-item .source { color: #999; font-size: 11px; }
.link-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  margin: 6px 0 14px;
}
.link-input:focus { outline: none; border-color: #4361ee; }

/* Status messages */
#level-status, #tilemap-status, #links-status, #pack-status {
  margin-top: 12px;
  font-size: 14px;
}
#level-status.success, #tilemap-status.success, #links-status.success, #pack-status.success { color: #2ec4b6; }
#level-status.error, #tilemap-status.error, #links-status.error, #pack-status.error, .upload-status.error { color: #e63946; }

/* Desc */
.desc { color: #777; margin-bottom: 16px; }

.step-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Level JSON */
.level-panels {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}
.level-panel {
  flex: 1;
  min-width: 0;
}
.level-panel h3 {
  font-size: 15px;
  margin-bottom: 4px;
  color: #1a1a2e;
}
.level-uuid {
  font-size: 11px;
  color: #999;
  margin-bottom: 8px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
}
.level-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 11px;
  line-height: 1.4;
  resize: vertical;
  background: #f8f9fa;
  color: #333;
}
.level-textarea:focus {
  outline: none;
  border-color: #4361ee;
}
.level-actions {
  margin-top: 8px;
}
.level-status {
  margin-top: 8px;
  font-size: 13px;
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* Responsive */
@media (max-width: 640px) {
  #app { padding: 12px; }
  .panel { padding: 16px; }
  .image-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .level-panels { flex-direction: column; }
}
