:root {
  --night: #140b24;
  --night-2: #1f1238;
  --card: rgba(39, 24, 66, 0.85);
  --pumpkin: #ff8a1f;
  --pumpkin-dark: #e06a00;
  --ghost: #f6f0ff;
  --muted: #b9a8d6;
  --error: #ff8f8f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ghost);
  background: radial-gradient(ellipse at top, var(--night-2), var(--night) 70%);
  background-attachment: fixed;
}

.sky { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.sky::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, #fff8, transparent),
    radial-gradient(1px 1px at 30% 70%, #fff6, transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, #fff9, transparent),
    radial-gradient(1px 1px at 75% 45%, #fff7, transparent),
    radial-gradient(1.5px 1.5px at 90% 80%, #fff8, transparent),
    radial-gradient(1px 1px at 45% 90%, #fff5, transparent);
}
.moon {
  position: absolute; top: 40px; right: 8%;
  width: 90px; height: 90px; border-radius: 50%;
  background: #fff6d8;
  box-shadow: 0 0 60px 20px #fff3c055;
}

header { text-align: center; padding: 48px 16px 8px; }
h1 {
  font-family: "Creepster", cursive;
  font-weight: 400;
  font-size: clamp(3rem, 10vw, 5rem);
  margin: 0;
  color: var(--pumpkin);
  letter-spacing: 2px;
  text-shadow: 0 4px 24px #ff8a1f66;
}
.tagline { color: var(--muted); margin: 8px 0 0; font-size: 1.1rem; }

main { max-width: 860px; margin: 0 auto; padding: 24px 16px 64px; }

.card {
  background: var(--card);
  border: 1px solid #ffffff14;
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
  backdrop-filter: blur(6px);
}

.drop {
  display: flex; align-items: center; justify-content: center;
  min-height: 240px;
  border: 2px dashed #ff8a1f88;
  border-radius: 16px;
  cursor: pointer;
  text-align: center;
  font-size: 1.2rem;
  overflow: hidden;
  transition: background 0.2s, border-color 0.2s;
}
.drop:hover, .drop.over { background: #ff8a1f14; border-color: var(--pumpkin); }
.drop small { color: var(--muted); font-size: 0.85rem; }
.drop img { max-width: 100%; max-height: 360px; display: block; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0; }
.fields label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.fields small { font-weight: 400; color: var(--muted); }
input[type="text"] {
  font: inherit;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #ffffff22;
  background: #0f0820;
  color: var(--ghost);
}
input[type="text"]:focus { outline: 2px solid var(--pumpkin); border-color: transparent; }

button, .button {
  font: inherit; font-weight: 700;
  display: inline-block;
  padding: 14px 24px;
  border: 0; border-radius: 999px;
  background: var(--pumpkin);
  color: #1a0d00;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, background 0.2s;
}
button:hover:not(:disabled), .button:hover { background: var(--pumpkin-dark); transform: translateY(-1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
#go { width: 100%; font-size: 1.15rem; }
.secondary { background: #ffffff14; color: var(--ghost); }
.secondary:hover { background: #ffffff24 !important; }

.note { color: var(--muted); font-size: 0.85rem; text-align: center; margin: 12px 0 0; }
.note.demo { color: var(--pumpkin); }

.loading { text-align: center; padding: 48px 24px; }
.cauldron { font-size: 4rem; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-12px) rotate(-6deg); } }
#loadingText { font-size: 1.2rem; color: var(--muted); }

.images { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.images figure { margin: 0; }
.images img, .images canvas { width: 100%; border-radius: 14px; display: block; aspect-ratio: 1; object-fit: cover; }
.images figcaption { text-align: center; color: var(--muted); margin-top: 8px; }
.images .button, .images .error, .images .note { grid-column: 1 / -1; justify-self: center; }

.story { font-family: "Lora", Georgia, serif; }
.story h2 { font-size: 1.8rem; color: var(--pumpkin); margin-top: 0; text-align: center; }
#storyBody p { font-size: 1.15rem; line-height: 1.8; margin: 0 0 1em; }
#storyBody p:first-child::first-letter {
  font-family: "Creepster", cursive;
  float: left; font-size: 3.4rem; line-height: 1; margin: 4px 8px 0 0; color: var(--pumpkin);
}
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; font-family: "Nunito", sans-serif; }

.error { color: var(--error); }

@media (max-width: 600px) {
  .fields, .images { grid-template-columns: 1fr; }
  .moon { width: 60px; height: 60px; }
}
