:root {
  --bg: #f8f4e8;
  --bg-glow: #fff8ee;
  --surface: #fffcf5;
  --ink: #203234;
  --ink-soft: #5a6f6f;
  --accent: #8b9a2f;
  --accent-dark: #5f6a18;
  --danger: #c13030;
  --radius: 18px;
  --shadow: 0 10px 28px rgba(95, 106, 24, 0.12);
}

* {
  box-sizing: border-box;
}

/* General Styling */
html,
body {
  margin: 0;
  padding: 0;
  font-family: "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, #fffbe7 0%, transparent 34%),
    radial-gradient(circle at 95% 8%, #f2f5de 0%, transparent 30%),
    linear-gradient(180deg, var(--bg-glow), var(--bg));
  color: var(--ink);
}

.app-shell {
  max-width: 560px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 16px 42px;
  position: relative; /* Added for bottom-action positioning */
}

.screen {
  display: none;
  animation: fade-in 0.25s ease;
  background: var(--surface);
  border: 1px solid #ebe0ce;
  border-radius: 26px;
  padding: 22px 18px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-head {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-card {
  background: linear-gradient(180deg, #f5eed0 0%, #f5efe7 100%);
  border: 1px solid #e7d8b5;
  border-radius: 30px;
  box-shadow: 0 18px 40px rgba(120, 98, 74, 0.1);
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
}

.icon-circle {
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffcf57 0%, #f596b7 100%);
  box-shadow: 0 14px 30px rgba(245, 150, 183, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px; /* Placeholder for icon */
  color: white;
}

.bottom-action {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 16px;
  background: linear-gradient(0deg, var(--bg) 0%, transparent 100%); /* Fading effect */
  z-index: 10;
  box-sizing: border-box;
}

.bottom-action button {
  margin-top: 0; /* Override default button margin-top */
}

h1 {
  font-size: 28px;
  font-weight: bold;
  line-height: 1.35;
  margin: 0 0 12px;
}

h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 14px;
}

h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 10px;
}

p {
  margin: 0 0 10px;
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
}

.subtitle {
  color: var(--ink-soft);
  margin-bottom: 16px;
}

ul.value-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0;
  margin: 0 auto 22px;
  list-style: none;
  justify-content: center;
}

.value-list li {
  background: #fdf6e6;
  border: 1px solid #e0d0b0;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  color: #6a7c66;
  white-space: nowrap;
}

textarea,
input {
  width: 100%;
  border: 1px solid #e0d0b0;
  border-radius: 16px;
  padding: 14px;
  font-size: 16px;
  color: var(--ink);
  background: #fffef8;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.draw-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

button {
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: 16px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 16px; /* Default margin for buttons */
}

.btn-primary {
  background: linear-gradient(135deg, #f596b7 0%, #ffcf57 100%);
  color: white;
  box-shadow: 0 8px 20px rgba(245, 150, 183, 0.28);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(245, 150, 183, 0.28);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-light);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.btn-ghost:active {
  transform: translateY(0);
}

.btn-text {
  background: none;
  border: none;
  color: var(--ink-light);
  font-size: 16px;
  padding: 8px;
  margin: 0;
  width: auto;
  text-decoration: underline;
}

.btn-text:hover {
  color: var(--ink);
}

.hint {
  font-size: 14px;
  color: var(--ink-light);
  text-align: center;
  margin-top: 10px;
}

.hint-row {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-light);
}

.error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  margin-top: 10px;
}

.result-block {
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid #e9dac4;
  background: #fffdf8;
  margin-bottom: 12px;
}

.card-head {
  margin-bottom: 8px;
}

.progress {
  color: var(--ink-soft);
  font-size: 14px;
}

.card-seq {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.card-chip {
  text-align: center;
  border-radius: 12px;
  border: 1px solid #d8caaf;
  background: #faf4e8;
  color: #64724e;
  padding: 8px 0;
  font-size: 13px;
  transition: all 0.2s ease;
}

.card-chip.active {
  border-color: #8b9a2f;
  color: #fff;
  background: linear-gradient(120deg, #8b9a2f, #66731e);
}

.card-stage {
  border-radius: 20px;
  border: 1px solid #e2d3bc;
  background: linear-gradient(180deg, #fffef9, #f6eedf 80%);
  padding: 12px;
  margin-bottom: 12px;
}

.card-visual-wrap {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  aspect-ratio: 600 / 951;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #d8c8ad;
  background: #ede3cd;
  position: relative;
}

#card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease;
}

#card-image.loaded {
  opacity: 1;
}

.card-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #5a6f6f;
  font-size: 14px;
  padding: 18px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.36), transparent 60%),
    linear-gradient(180deg, #f0e6d0, #e4d7bc);
}

.card-meta {
  padding-top: 11px;
}

.card-number {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}



.input-panel {
  border-radius: 16px;
  border: 1px solid #e4d7c2;
  background: #fffdf7;
  padding: 12px;
  margin-bottom: 10px;
}

.input-panel label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #32484a;
}

.progress-wrap {
  height: 8px;
  background-color: #f0e6d0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar {
  height: 100%;
  width: 0%; /* Controlled by JS */
  background: linear-gradient(90deg, #e7b933 0%, #eb8fa9 100%);
  border-radius: 999px;
  transition: width 0.3s ease-in-out;
}

.spinner {
  margin: 18vh auto 16px;
  width: 46px;
  height: 46px;
  border: 4px solid #e2dcc6;
  border-top-color: #8b9a2f;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.result-actions button {
  margin-top: 10px;
  width: 50%;
}

#share-canvas {
  margin-top: 12px;
  width: 100%;
  border-radius: 16px;
  border: 1px solid #d8c7ac;
  background: #fff;
}

@media (min-width: 480px) {
  .screen {
    padding: 22px 20px 22px;
  }

  .draw-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
