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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

header h1 { font-size: 1.5rem; }

.header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

main { max-width: 900px; margin: 2rem auto; padding: 0 1rem; }

.hunt-settings {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.hunt-settings label {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.hunt-settings input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
}

/* Buttons */
.btn {
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.btn:active { transform: translateY(0); }
.btn-primary { background: #667eea; color: white; }
.btn-secondary { background: rgba(255,255,255,0.2); color: white; border: 1px solid rgba(255,255,255,0.3); }
.btn-danger { background: #e74c3c; color: white; }
.btn-qr { background: #00b894; color: white; }
.btn-preview { background: #6c5ce7; color: white; }
.btn-add {
  display: block;
  width: 100%;
  padding: 1rem;
  margin-top: 1rem;
  background: white;
  border: 2px dashed #ccc;
  border-radius: 12px;
  font-size: 1.1rem;
  color: #888;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-add:hover { border-color: #667eea; color: #667eea; }

/* Clue Cards */
.clue-list { display: flex; flex-direction: column; gap: 0.75rem; }

.clue-card {
  background: white;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  user-select: none;
}
.clue-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); transform: translateY(-1px); }
.clue-card.dragging { opacity: 0.5; transform: scale(0.98); }
.clue-card .drag-handle {
  cursor: grab;
  font-size: 1.2rem;
  color: #ccc;
  padding: 0.25rem;
}
.clue-card .drag-handle:active { cursor: grabbing; }

.clue-card .clue-order {
  background: #667eea;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.clue-card .clue-emoji { font-size: 1.5rem; flex-shrink: 0; }

.clue-card .clue-info { flex: 1; min-width: 0; }
.clue-card .clue-info h3 { font-size: 1rem; margin-bottom: 0.15rem; }
.clue-card .clue-info .clue-meta {
  font-size: 0.8rem;
  color: #888;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.clue-card .card-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}
.card-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background 0.15s, transform 0.1s;
}
.card-action-btn:hover { transform: scale(1.1); }
.card-action-btn.preview-btn { background: #e8e4ff; color: #6c5ce7; }
.card-action-btn.preview-btn:hover { background: #d5ceff; }
.card-action-btn.qr-btn { background: #d4f5ed; color: #00b894; }
.card-action-btn.qr-btn:hover { background: #b8eddf; }

.clue-card .clue-preview {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
  overflow: hidden;
}
.clue-card .clue-preview img { width: 100%; height: 100%; object-fit: cover; }

.type-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.type-badge[data-type="text"] { background: #e8f5e9; color: #2e7d32; }
.type-badge[data-type="image"] { background: #e3f2fd; color: #1565c0; }
.type-badge[data-type="anagram"] { background: #fff3e0; color: #e65100; }
.type-badge[data-type="anagram-input"] { background: #fce4ec; color: #c62828; }
.type-badge[data-type="flappy"] { background: #fff9c4; color: #f57f17; }
.type-badge[data-type="snake"] { background: #e8f5e9; color: #1b5e20; }
.type-badge[data-type="temple"] { background: #efebe9; color: #4e342e; }
.type-badge[data-type="crossy"] { background: #e8eaf6; color: #283593; }
.type-badge[data-type="audio"] { background: #f3e5f5; color: #6a1b9a; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1.2rem; }
.modal-header-actions { display: flex; align-items: center; gap: 0.75rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  padding: 0.25rem;
  line-height: 1;
}
.modal-close:hover { color: #333; }

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  flex: 1;
}
.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.modal-body input,
.modal-body textarea,
.modal-body select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}
.modal-body textarea { resize: vertical; }
.modal-body hr { border: none; border-top: 1px solid #eee; }

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row label { flex: 1; min-width: 120px; }

.type-fields { display: flex; flex-direction: column; gap: 1rem; }

.image-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  overflow: hidden;
}
.image-preview img { max-width: 100%; max-height: 200px; object-fit: contain; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 600px) {
  header { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; }
  .header-actions .btn { flex: 1; text-align: center; font-size: 0.8rem; padding: 0.5rem; }
  .clue-card .card-actions { flex-direction: column; gap: 0.25rem; }
  .card-action-btn { width: 30px; height: 30px; font-size: 0.85rem; }
}
