:root {
  --bg-top: #0a1a0e;
  --bg-bottom: #1a3520;
  --fg: #e8f2dc;
  --dim: #7a9c6e;
  --accent: #cfe6c2;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 200, 130, 0.08), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(155, 227, 163, 0.07), transparent 55%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--fg);
  font-family: Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* drifting petals layer behind the card — subtle ambient motion */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.ambient .petal {
  position: absolute;
  top: -30px;
  width: 14px;
  height: 14px;
  border-radius: 14px 2px 14px 2px;
  opacity: 0;
  animation: petal-fall var(--dur, 22s) linear infinite;
  animation-delay: var(--delay, 0s);
  transform-origin: center;
}
@keyframes petal-fall {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  8%   { opacity: 0.55; }
  50%  { transform: translate(var(--drift, 60px), 50dvh) rotate(180deg); opacity: 0.5; }
  100% { transform: translate(calc(var(--drift, 60px) * 0.4), 110dvh) rotate(360deg); opacity: 0; }
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.card {
  width: min(640px, calc(100vw - 32px));
  min-width: 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 28px 22px;
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 1;
  animation: card-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

/* Stagger the children of the first card so each element drifts in. */
#form-view > header,
#form-view > form .field,
#form-view > form button,
#form-view > .err {
  animation: lift-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  opacity: 0;
}
#form-view > header             { animation-delay: 0.10s; }
#form-view > form .field:nth-of-type(1) { animation-delay: 0.20s; }
#form-view > form .field:nth-of-type(2) { animation-delay: 0.30s; }
#form-view > form .field:nth-of-type(3) { animation-delay: 0.40s; }
#form-view > form button        { animation-delay: 0.55s; }

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

.hidden { display: none; }

h1, h2 {
  margin: 0 0 6px;
  font-weight: normal;
  letter-spacing: 0.01em;
}

h1 { font-size: 28px; }
h2.big { font-size: 26px; text-align: center; }

.sub {
  color: var(--dim);
  margin: 0 0 22px;
  line-height: 1.4;
}

.sub.small { font-size: 13px; text-align: center; }

.field {
  display: block;
  min-width: 0;
  margin-bottom: 18px;
}

.field span {
  display: block;
  color: var(--dim);
  font-size: 14px;
  margin-bottom: 6px;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 17px;
  background: rgba(0,0,0,0.25);
  color: var(--fg);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

input[type="color"] {
  width: 88px;
  height: 48px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.garden-picker {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  -webkit-overflow-scrolling: touch;
  cursor: crosshair;
}

.garden-stage {
  position: relative;
  width: 960px;
  height: 240px;
}

#garden-preview {
  display: block;
  width: 960px;
  height: 240px;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}

.plant-marker {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  border: 2px solid var(--marker-color, var(--accent));
  border-radius: 50%;
  box-shadow:
    0 0 0 5px color-mix(in srgb, var(--marker-color, var(--accent)) 22%, transparent),
    0 0 22px color-mix(in srgb, var(--marker-color, var(--accent)) 55%, transparent);
  pointer-events: none;
  animation: marker-pulse 2.4s ease-in-out infinite;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

@keyframes marker-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50%      { transform: translateX(-50%) scale(1.15); }
}

.plant-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 22px;
  background: color-mix(in srgb, var(--marker-color, var(--accent)) 75%, transparent);
  transform: translateX(-50%);
}

button {
  width: 100%;
  padding: 14px;
  margin-top: 4px;
  border: none;
  border-radius: 12px;
  font: inherit;
  font-size: 18px;
  background: linear-gradient(135deg, var(--accent), #e6f3d6);
  color: #0a1a0e;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.25s ease;
  box-shadow: 0 4px 18px rgba(207,230,194,0.18);
}

button:hover { box-shadow: 0 6px 26px rgba(207,230,194,0.32); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: wait; }

.err {
  color: #e3a3a3;
  font-size: 14px;
  min-height: 1.2em;
  margin: 8px 0 0;
}

.souvenir-wrap {
  display: flex;
  justify-content: center;
  margin: 18px 0;
}

#souvenir {
  width: 200px;
  height: 300px;
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
}

.link {
  display: block;
  text-align: center;
  color: var(--accent);
  text-decoration: none;
  padding: 10px;
  margin-top: 8px;
}

.link:active { color: var(--fg); }

@media (max-width: 480px) {
  body { padding: 12px; }
  .card {
    width: calc(100vw - 24px);
    padding: 22px 16px;
  }
  .garden-stage,
  #garden-preview {
    width: 840px;
    height: 210px;
  }
}

/* Fireflies — pure CSS drift, no JS animation loop */
.fireflies {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.firefly {
  position: absolute;
  left: var(--left, 50%);
  bottom: -10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at center,
    hsla(var(--hue, 60), 95%, 78%, 0.95) 0%,
    hsla(var(--hue, 60), 95%, 60%, 0.4) 45%,
    transparent 75%);
  box-shadow: 0 0 12px hsla(var(--hue, 60), 95%, 70%, 0.55);
  animation: drift var(--dur, 18s) linear infinite;
  animation-delay: var(--delay, 0s);
  opacity: 0;
}

@keyframes drift {
  0%   { transform: translate(0, 0) scale(0.6); opacity: 0; }
  10%  { opacity: 0.95; }
  35%  { transform: translate(var(--sway1, 30px), -35%) scale(1); opacity: 0.9; }
  60%  { transform: translate(var(--sway2, -25px), -65%) scale(0.85); opacity: 0.85; }
  90%  { transform: translate(var(--sway3, 20px), -95%) scale(0.55); opacity: 0.5; }
  100% { transform: translate(var(--sway4, 0px), -110%) scale(0.4); opacity: 0; }
}

#garden-picker { position: relative; }

/* Bloom-burst around the souvenir on success */
.bloom-burst {
  position: absolute;
  inset: -30px;
  border-radius: 50%;
  background: radial-gradient(circle at center,
    rgba(207,230,194,0.5) 0%,
    rgba(207,230,194,0.18) 35%,
    transparent 70%);
  animation: bloom-burst 1.7s ease-out forwards;
  pointer-events: none;
}

@keyframes bloom-burst {
  0%   { transform: scale(0.4); opacity: 0; }
  20%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

.souvenir-wrap { position: relative; }

/* Haiku reveal on success page */
.haiku {
  margin: 18px 6px 4px;
  text-align: center;
  font-style: italic;
  font-size: 17px;
  line-height: 1.55;
  color: var(--accent);
  min-height: 84px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.haiku.visible {
  opacity: 1;
  transform: translateY(0);
}
.haiku-line { display: block; }
.haiku.pending {
  font-style: normal;
  color: var(--dim);
  opacity: 0.7;
  font-size: 14px;
}
