* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f172a;
  color: #f8fafc;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
}

.container { max-width: 900px; margin: 0 auto; }

header {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

h1 {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
  font-size: 1.8rem;
}

.subtitle {
  color: #64748b;
  margin: 0;
  font-size: 14px;
}

.controls {
  background: #1e293b;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.row {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.field { flex: 1; min-width: 200px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

label {
  display: block;
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 5px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #f8fafc;
  font-size: 16px;
}

input:focus {
  outline: none;
  border-color: #8b5cf6;
}

button {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
  min-width: 200px;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

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

.btn-secondary { background: #334155; color: #f8fafc; }
.btn-secondary:hover { background: #475569; }

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.preview-container {
  background: #1e293b;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  position: relative;
  min-height: 540px;
}

#fortune-svg {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 41, 59, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  z-index: 10;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #334155;
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 15px;
  color: #94a3b8;
  font-size: 14px;
}

.progress-bar {
  width: 80%;
  max-width: 300px;
  height: 8px;
  background: #334155;
  border-radius: 4px;
  margin-top: 15px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-stage {
  margin-top: 8px;
  color: #64748b;
  font-size: 12px;
}

.hidden { display: none !important; }

.error {
  background: #7f1d1d;
  color: #fecaca;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 15px;
}

.btn-icon {
  background: #334155;
  color: #94a3b8;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: #475569; color: #f8fafc; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: #1e293b;
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
}

.modal h3 {
  margin: 0 0 16px 0;
  color: #8b5cf6;
}

.modal .field { margin-bottom: 12px; }

.modal .hint {
  font-size: 12px;
  color: #64748b;
  margin: 8px 0 16px 0;
}

.modal .hint a {
  color: #8b5cf6;
}

.how-to-play {
  background: #1e293b;
  border-radius: 12px;
  padding: 20px;
  margin-top: 20px;
}

.how-to-play h3 {
  color: #8b5cf6;
  margin-top: 0;
  margin-bottom: 15px;
}

.how-to-play ol {
  color: #94a3b8;
  line-height: 1.8;
  margin: 0;
  padding-left: 20px;
}

@media print {
  body * { visibility: hidden; }
  #fortune-svg, #fortune-svg * { visibility: visible; }
  #fortune-svg {
    position: absolute;
    left: 0;
    top: 0;
    width: 100vmin;
    height: 100vmin;
  }
  body { background: white; }
}
