/* ===== Global Reset & Base ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f0f13;
  color: #f0f0f5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Question Box ===== */
.question-box {
  max-width: 480px;
  margin: 0 auto 1.4rem;
  text-align: left;
}

.question-box label {
  display: block;
  font-size: 0.85rem;
  color: #a0a0b8;
  margin-bottom: 0.4rem;
  letter-spacing: 0.03em;
}

.question-box textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #f0f0f5;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.2s ease;
}

.question-box textarea:focus {
  outline: none;
  border-color: #7b6fd4;
}

.question-box textarea::placeholder {
  color: #70708a;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 1.5rem 1rem 1rem;
}

.app-header h1 {
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 1rem;
}

.primary-btn {
  background: #4a3f8c;
  color: white;
  border: none;
  padding: 0.7rem 1.6rem;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.primary-btn:hover {
  background: #5c4fad;
}


.question-box {
  max-width: 480px;
  margin: 0 auto 1.4rem;
  text-align: left;
}

.question-box label {
  display: block;
  font-size: 0.85rem;
  color: #a0a0b8;
  margin-bottom: 0.4rem;
  letter-spacing: 0.03em;
}

.question-box textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #f0f0f5;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  transition: border-color 0.2s ease;
}

.question-box textarea:focus {
  outline: none;
  border-color: #7b6fd4;
}

.question-box textarea::placeholder {
  color: #70708a;
}

/* ===== Main Layout – Centers cards vertically & horizontally ===== */
.app-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;   /* vertical centering */
  align-items: center;       /* horizontal centering */
  padding: 1rem;
  gap: 2.5rem;
}

/* ===== Cards Row – side by side ===== */
.cards-grid {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1.8rem;
  flex-wrap: nowrap;         /* keep on one row */
}

/* Individual card slot */
.card-slot {
  width: 180px;
  text-align: center;
}

.position-label {
  display: block;
  font-size: 0.8rem;
  color: #a0a0b8;
  margin-bottom: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* 3D Card Container */
.card-inner {
  position: relative;
  width: 180px;
  height: 300px;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.4, 0.0, 0.2, 1);
  cursor: pointer;
  border-radius: 10px;
}

.card-inner.flipped {
  transform: rotateY(180deg);
}

/* Front & Back faces */
.card-back,
.card-front {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.card-back img,
.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Front face starts rotated so the back is visible first */
.card-front {
  transform: rotateY(180deg);
}

/* Card title under each card */
.card-title {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #c8c8d8;
  min-height: 2.6em;
  line-height: 1.3;
}

/* ===== Narrative Section ===== */
.narrative-section {
  max-width: 720px;
  width: 100%;
  text-align: center;
  padding: 0 1rem;
}

.status-text {
  color: #a0a0b8;
  font-size: 1.05rem;
}

.narrative-content {
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 1.5rem 1.8rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.synthesis-header {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: #e0e0f0;
  text-align: center;
}

.narrative-p {
  margin-bottom: 1rem;
  line-height: 1.55;
  color: #d0d0e0;
}

.narrative-p:last-child {
  margin-bottom: 0;
}

/* Fade-in animation for the narrative */
.fade-in {
  animation: fadeIn 0.7s ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive adjustments ===== */
@media (max-width: 640px) {
  .cards-grid {
    gap: 1rem;
  }

  .card-slot {
    width: 140px;
  }

  .card-inner {
    width: 140px;
    height: 233px;
  }

  .app-header h1 {
    font-size: 1.5rem;
  }
}