/* ====== BASE ====== */
:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-light: #1c2a4a;
  --border: #2a3a5c;
  --accent: #64c8ff;
  --accent-hover: #8ad8ff;
  --gold: #ffd700;
  --text: #e0e0e0;
  --text-muted: #8899aa;
  --danger: #ff6b6b;
  --success: #51cf66;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ====== HEADER ====== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.site-header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
}

.site-header .demo-link {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid var(--gold);
  padding: 6px 14px;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.site-header .demo-link:hover {
  background: rgba(255, 215, 0, 0.15);
}

/* ====== PROGRESS BAR ====== */
.progress-bar {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 20px 24px 10px;
  max-width: 700px;
  margin: 0 auto;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-step .num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  background: var(--surface);
  border: 2px solid var(--border);
  transition: all 0.3s;
}

.progress-step.active .num {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.progress-step.completed .num {
  background: var(--success);
  border-color: var(--success);
  color: var(--bg);
}

.progress-step .label {
  display: none;
}

.progress-connector {
  width: 30px;
  height: 2px;
  background: var(--border);
  align-self: center;
}

.progress-connector.completed {
  background: var(--success);
}

@media (min-width: 600px) {
  .progress-step .label { display: inline; }
  .progress-connector { width: 50px; }
}

/* ====== WIZARD CONTAINER ====== */
.wizard-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 10px 20px 40px;
}

.step {
  display: none;
}

.step.active {
  display: block;
}

.step-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--accent);
}

.step-description {
  color: var(--text-muted);
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ====== STEP 1: IMAGE ====== */
.image-options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.upload-area {
  flex: 1;
  min-width: 200px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
}

.upload-area:hover {
  border-color: var(--accent);
  background: var(--surface-light);
}

.upload-area .upload-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

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

.demo-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 28px;
  background: var(--surface);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 500;
}

.demo-btn:hover {
  background: rgba(255, 215, 0, 0.1);
}

.demo-btn .demo-icon {
  font-size: 2rem;
  margin-bottom: 6px;
}

.image-preview {
  display: none;
  margin-top: 16px;
  text-align: center;
}

.image-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.image-preview .filename {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

.image-preview .change-btn {
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  margin-top: 4px;
  text-decoration: underline;
}

/* ====== STEP 2: ZONE EDITOR ====== */
.zone-editor-layout {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.canvas-container {
  flex: 1 1 60%;
  min-width: 300px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.canvas-container canvas {
  display: block;
  width: 100%;
  height: auto;
}

.zone-sidebar {
  flex: 1 1 250px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.zone-instructions {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  border: 1px solid var(--border);
}

.zone-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 400px;
  overflow-y: auto;
}

.zone-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.zone-card:hover {
  border-color: var(--accent);
}

.zone-card.selected {
  border-color: var(--accent);
  background: var(--surface-light);
}

.zone-card .zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.zone-card .zone-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.zone-card .zone-badges {
  display: flex;
  gap: 4px;
}

.zone-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.zone-badge.key {
  background: rgba(255, 215, 0, 0.2);
  color: var(--gold);
}

.zone-badge.door {
  background: rgba(100, 200, 255, 0.2);
  color: var(--accent);
}

.zone-card .zone-message-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zone-card .zone-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.zone-card .zone-actions button {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.zone-card .zone-actions button:hover {
  border-color: var(--text);
  color: var(--text);
}

.zone-card .zone-actions .delete-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Zone edit form */
.zone-edit-form {
  display: none;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px;
}

.zone-edit-form.active {
  display: block;
}

.zone-edit-form h4 {
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: var(--accent);
}

.zone-edit-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 10px;
}

.zone-edit-form label:first-of-type {
  margin-top: 0;
}

.zone-edit-form input,
.zone-edit-form textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

.zone-edit-form textarea {
  min-height: 60px;
  resize: vertical;
}

.zone-edit-form .form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ====== STEP 3: KEY & DOOR ====== */
.assign-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 500px;
}

.assign-group label {
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.assign-group .assign-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.assign-group select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
}

/* ====== STEP 4: WIN MESSAGE ====== */
.win-message-section {
  max-width: 550px;
}

.win-message-section textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  line-height: 1.5;
}

.win-message-section .char-count {
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ====== STEP 5: PREVIEW & DOWNLOAD ====== */
.preview-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-frame {
  width: 100%;
  height: 500px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #111;
}

.download-section {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.download-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ====== NAVIGATION ====== */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ====== BUTTONS ====== */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--text-muted);
}

.btn-gold {
  background: var(--gold);
  color: var(--bg);
  font-weight: 600;
}

.btn-gold:hover {
  background: #ffdd33;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.15);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ====== VALIDATION MESSAGES ====== */
.validation-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 8px;
  display: none;
}

.validation-msg.visible {
  display: block;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 700px) {
  .zone-editor-layout {
    flex-direction: column;
  }
  .zone-sidebar {
    max-width: none;
  }
  .preview-frame {
    height: 350px;
  }
}

/* Hidden file input */
#image-upload {
  display: none;
}
