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

/* === BASE === */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0a0a0f;
  color: #f0f0f5;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* === PROGRESS BAR === */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 24px 12px;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.progress-steps {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}

.step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #2a2a3e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #444466;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease,
              box-shadow 180ms ease;
}

.step.active {
  border-color: #7c5cfc;
  color: #7c5cfc;
  animation: stepPulse 2.4s ease-in-out infinite;
}

.step.done {
  border-color: #7c5cfc;
  background: #7c5cfc;
  color: #fff;
  animation: none;
}

@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 252, 0.45); }
  50%       { box-shadow: 0 0 0 5px rgba(124, 92, 252, 0); }
}

.progress-track {
  height: 3px;
  background: #1a1a2e;
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c5cfc, #c77dff);
  border-radius: 2px;
  width: 0%;
  transition: width 240ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* === WIZARD MAIN === */
.wizard {
  position: fixed;
  inset: 0;
  padding-top: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === SCREENS === */
.screen {
  display: flex;
  position: absolute;
  inset: 0;
  padding-top: 80px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-left: 24px;
  padding-right: 24px;
  padding-bottom: 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, visibility 180ms ease, transform 180ms ease;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* === STEP PROMPT === */
.step-prompt {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 600;
  text-align: center;
  margin-bottom: 32px;
  color: #f0f0f5;
  letter-spacing: -0.02em;
}

/* === CARDS GRID === */
.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  max-width: 840px;
  width: 100%;
}

/* === CARD === */
.card {
  min-width: 120px;
  min-height: 64px;
  padding: 16px 20px;
  background: #12121f;
  border: 2px solid #2a2a3e;
  border-radius: 14px;
  color: #c0c0e0;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease,
              box-shadow 140ms ease, transform 140ms ease;
  touch-action: manipulation;
}

.card:hover {
  border-color: #7c5cfc;
  color: #f0f0f5;
  box-shadow: 0 0 16px rgba(124, 92, 252, 0.2);
}

.card:active {
  transform: scale(0.96);
}

.card.selected {
  border-color: #7c5cfc;
  background: rgba(124, 92, 252, 0.18);
  color: #f0f0f5;
  box-shadow: 0 0 24px rgba(124, 92, 252, 0.35);
  transform: translateY(-2px);
}

/* === NEXT BUTTON === */
.btn-next {
  margin-top: 28px;
  padding: 14px 40px;
  background: #7c5cfc;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, transform 80ms ease, box-shadow 140ms ease;
  touch-action: manipulation;
  box-shadow: 0 4px 20px rgba(124, 92, 252, 0.4);
}

.btn-next:hover {
  background: #9070ff;
  box-shadow: 0 4px 28px rgba(124, 92, 252, 0.6);
}

.btn-next:active {
  transform: scale(0.97);
}

.btn-next:disabled {
  background: #1e1e30;
  color: #44446a;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* === STEP 1 TWO-GROUP LAYOUT === */
.step1-groups {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 840px;
}

.card-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.card-group-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #4a4a7a;
}

/* === NAME INPUT === */
.name-input {
  width: 100%;
  padding: 16px 20px;
  background: #12121f;
  border: 2px solid #2a2a3e;
  border-radius: 14px;
  color: #f0f0f5;
  font-family: inherit;
  font-size: 1.1rem;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.name-input:focus {
  border-color: #7c5cfc;
  box-shadow: 0 0 16px rgba(124, 92, 252, 0.2);
}

/* === RANDOM NAME BUTTON === */
.btn-random {
  min-height: 48px;
  padding: 12px 28px;
  background: transparent;
  border: 2px solid #2a2a3e;
  border-radius: 12px;
  color: #8080a8;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease;
  touch-action: manipulation;
}

.btn-random:hover {
  border-color: #7c5cfc;
  color: #c0c0e0;
}

/* === NAME INPUT AREA === */
.name-input-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 420px;
}

/* === LOADING === */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  color: #8080a0;
  font-size: 1.1rem;
  font-weight: 300;
  letter-spacing: 0.02em;
}

.loading-content p {
  animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

.spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #7c5cfc;
  border-right-color: rgba(124, 92, 252, 0.35);
  animation: spin 0.85s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
  filter: drop-shadow(0 0 8px rgba(124, 92, 252, 0.5));
}

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

/* === RESULT SCREENS === */
.result-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  text-align: center;
  max-width: 600px;
  width: 100%;
}

.result-image-wrap {
  position: relative;
  width: min(700px, 80vw);
  height: min(700px, 80vw);
  border-radius: 20px;
  overflow: hidden;
  background: #1a1a2e;
  box-shadow: 0 0 60px rgba(124, 92, 252, 0.25), 0 0 120px rgba(124, 92, 252, 0.1);
  animation: float 5s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.result-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 600ms ease;
}

.result-image.loaded {
  opacity: 1;
}

.result-image-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #1a1a2e;
}

.result-image-wrap.fallback .result-image {
  display: none;
}

.result-image-wrap.fallback .result-image-fallback {
  display: flex;
}

.fallback-icon {
  position: relative;
  width: 60px;
  height: 80px;
}

.fallback-icon::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(124, 92, 252, 0.3);
  border: 1px solid rgba(124, 92, 252, 0.6);
}

.fallback-icon::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 46px;
  border-radius: 22px 22px 0 0;
  background: rgba(124, 92, 252, 0.2);
  border: 1px solid rgba(124, 92, 252, 0.4);
  border-bottom: none;
}

.fallback-label {
  font-size: 12px;
  font-weight: 400;
  color: rgba(192, 192, 224, 0.4);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.result-text {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 300;
  color: #c0c0e0;
  letter-spacing: 0.04em;
}

.reward-text {
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 700;
  color: #f0f0f5;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

#screen-result-2.active .reward-text {
  animation: fadeUp 380ms cubic-bezier(0.2, 0, 0.2, 1) both;
}

.reflection-text {
  font-size: clamp(1.1rem, 3.5vw, 1.8rem);
  font-weight: 300;
  color: #9090b8;
  font-style: italic;
  line-height: 1.6;
}

#screen-result-3.active .reflection-text {
  animation: fadeUp 400ms 600ms cubic-bezier(0.2, 0, 0.2, 1) both;
}

.result-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  animation: fadeUp 400ms 600ms cubic-bezier(0.2, 0, 0.2, 1) both;
}

.btn-result-action {
  padding: 14px 28px;
  border-radius: 12px;
  border: 1px solid rgba(124, 92, 252, 0.4);
  background: rgba(124, 92, 252, 0.12);
  color: #c0c0e0;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.btn-result-action:hover,
.btn-result-action:focus-visible {
  background: rgba(124, 92, 252, 0.28);
  border-color: rgba(124, 92, 252, 0.7);
  color: #f0f0f5;
  outline: none;
}

.btn-result-restart {
  border-color: rgba(192, 192, 224, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

.btn-result-restart:hover,
.btn-result-restart:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(192, 192, 224, 0.4);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
