:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --ink: #351a12;
  --deep: #2c2a17;
  --cream: #fff3d4;
  --butter: #ffd875;
  --coral: #ef6f5e;
  --lilac: #b9a0d8;
  --sage: #7fa36d;
  --green: #416c3d;
  --shadow: rgba(61, 31, 8, .22);
  --paper: rgba(255, 242, 206, .78);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: #f6b85c;
  color: var(--ink);
  font-family: "Segoe Print", "Bradley Hand", "Comic Sans MS", "Kaiti SC", "KaiTi", cursive;
  touch-action: manipulation;
}

button, a, summary { font: inherit; color: inherit; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.app {
  position: relative;
  min-height: 100svh;
  padding-top: var(--eazo-safe-area-top);
  padding-bottom: var(--eazo-safe-area-bottom);
  isolation: isolate;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 244, 185, .94) 0 8rem, transparent 8.2rem),
    linear-gradient(180deg, #ffbf67 0%, #f7aa66 36%, #e9b66d 54%, #a1b56c 55%, #668848 100%);
}

.app::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(ellipse at 18% 24%, rgba(255, 247, 184, .55), transparent 31%),
    linear-gradient(106deg, transparent 0 19%, rgba(255, 232, 150, .24) 22%, transparent 56%),
    linear-gradient(99deg, transparent 0 30%, rgba(255, 240, 177, .2) 33%, transparent 72%);
  pointer-events: none;
}

.app::after {
  content: "";
  position: absolute;
  left: -12%; right: -12%; bottom: -5%;
  height: 42%;
  z-index: -2;
  background:
    radial-gradient(ellipse at 8% 100%, #476f40 0 28%, transparent 29%),
    radial-gradient(ellipse at 36% 100%, #8ba65d 0 34%, transparent 35%),
    radial-gradient(ellipse at 74% 100%, #5d8249 0 32%, transparent 33%),
    radial-gradient(ellipse at 102% 100%, #3f6a3b 0 28%, transparent 29%);
  pointer-events: none;
}

.top-rail {
  position: relative;
  z-index: 4;
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 0 clamp(14px, 4vw, 30px) 6px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(25px, 8vw, 56px);
  line-height: .96;
  letter-spacing: -.04em;
  font-weight: 700;
  color: #3b2014;
  text-shadow: 0 1px 0 rgba(255, 243, 201, .7);
}

.instruction {
  grid-column: 1 / -1;
  width: min(680px, 100%);
  margin: 2px 0 0;
  padding: 8px 12px;
  border: 1.5px solid rgba(90, 55, 27, .18);
  border-radius: 999px 999px 999px 28px;
  background: rgba(255, 244, 213, .56);
  box-shadow: 0 12px 30px rgba(96, 51, 18, .09);
  font-size: clamp(13px, 3.45vw, 18px);
  line-height: 1.28;
  color: #4b2919;
}

.lang {
  min-width: 74px;
  min-height: 44px;
  border: 1.5px solid rgba(65, 48, 20, .2);
  border-radius: 999px;
  background: rgba(255, 242, 206, .78);
  box-shadow: 0 10px 24px rgba(73, 35, 10, .12);
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0 clamp(10px, 3vw, 24px) 0;
  display: grid;
  grid-template-rows: minmax(310px, 1fr) auto;
  gap: 0;
}

.meadow {
  position: relative;
  min-height: 310px;
  overflow: hidden;
  border-radius: 34px 34px 18px 18px;
  background:
    linear-gradient(180deg, rgba(255, 239, 171, .06) 0 48%, rgba(118, 147, 74, .38) 48.2% 100%),
    radial-gradient(ellipse at 30% 75%, rgba(255, 237, 174, .18), transparent 42%);
  box-shadow: inset 0 -34px 70px rgba(55, 91, 43, .16);
}

.horizon {
  position: absolute;
  left: -6%; right: -6%; top: 45%;
  height: 3px;
  background: rgba(90, 112, 54, .24);
  border-radius: 50%;
  transform: rotate(-.7deg);
}

.light-band {
  position: absolute;
  left: 7%; top: 23%;
  width: 102%; height: 34%;
  transform: rotate(-7deg);
  transform-origin: left center;
  background: linear-gradient(90deg, rgba(255, 248, 195, .72), rgba(255, 214, 117, .28), transparent 80%);
  filter: blur(1px);
  pointer-events: none;
}

.grass-layer, .pollen-layer, .flower-layer, .toast-layer, .puff-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grass-blade {
  position: absolute;
  bottom: -8px;
  width: 2px;
  height: var(--h);
  border-radius: 999px 999px 0 0;
  background: linear-gradient(180deg, rgba(255, 231, 141, .55), rgba(49, 98, 43, .85));
  transform-origin: bottom center;
  transform: rotate(var(--r));
  animation: grassSway var(--d) ease-in-out infinite alternate;
  opacity: var(--o);
}

@keyframes grassSway { to { transform: rotate(calc(var(--r) + 5deg)); } }

.pollen {
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255, 245, 174, .82);
  box-shadow: 0 0 11px rgba(255, 243, 163, .75);
  animation: floatPollen var(--t) ease-in-out infinite alternate;
  opacity: .85;
}

@keyframes floatPollen { to { transform: translate(14px, -18px); opacity: .52; } }

.flower-btn {
  position: absolute;
  width: var(--size);
  height: var(--size);
  min-width: 44px;
  min-height: 44px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  animation: flowerSway var(--sway) ease-in-out infinite alternate;
  z-index: var(--z);
}

.flower-btn.picked { display: none; }
.flower-btn.lifting { animation: liftAway .45s cubic-bezier(.22,.75,.23,1) forwards; }

@keyframes flowerSway {
  from { transform: translate(-50%, -50%) rotate(-2deg); }
  to { transform: translate(-50%, -52%) rotate(2deg); }
}
@keyframes liftAway {
  0% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { transform: translate(-50%, -105%) scale(1.16) rotate(-5deg); opacity: 0; }
}

.flower-svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 7px 5px rgba(59, 45, 21, .15)); }
.stem { stroke: #3f7842; stroke-width: 4; stroke-linecap: round; fill: none; }
.leaf { fill: #6f9b55; opacity: .9; }
.petal { stroke: rgba(65, 32, 18, .18); stroke-width: 1.1; }
.center { fill: #ffe28c; stroke: rgba(72, 39, 16, .22); stroke-width: 1.4; }

.toast {
  position: absolute;
  left: 50%; top: 34%;
  max-width: min(84%, 420px);
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  border-radius: 22px 22px 22px 8px;
  background: rgba(255, 245, 219, .86);
  border: 1.5px solid rgba(86, 54, 24, .16);
  box-shadow: 0 16px 36px rgba(70, 33, 12, .14);
  font-size: clamp(18px, 5vw, 30px);
  line-height: 1.2;
  color: #482515;
  opacity: 0;
  pointer-events: none;
  animation: lineToast 1.45s ease both;
  text-align: center;
}

@keyframes lineToast {
  0% { opacity: 0; transform: translate(-50%, -38%) scale(.96); }
  18%, 74% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -66%) scale(.98); }
}

.puff {
  position: absolute;
  width: 44px; height: 24px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  animation: puff .62s ease-out both;
}

.puff span {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 236, 176, .72);
  width: 18px; height: 18px;
}
.puff span:nth-child(2) { left: 12px; top: -7px; width: 22px; height: 22px; }
.puff span:nth-child(3) { left: 25px; top: 4px; width: 16px; height: 16px; }
@keyframes puff { 0%{opacity:1; transform:translate(-50%,-30%) scale(.6)} 100%{opacity:0; transform:translate(-50%,-80%) scale(1.4)} }

.bundle-rail {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(790px, 100%);
  margin: -26px auto 0;
  padding: 9px 10px;
  border-radius: 30px;
  background: rgba(255, 238, 199, .66);
  border: 1.5px solid rgba(75, 46, 20, .16);
  box-shadow: 0 18px 50px rgba(70, 41, 14, .18);
  backdrop-filter: blur(7px);
}

.count {
  width: 54px;
  text-align: center;
  font-size: 18px;
  color: #58301d;
  white-space: nowrap;
}

.slots {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 6px;
  align-items: end;
}

.slot {
  min-width: 44px;
  min-height: 58px;
  border: 1.4px dashed rgba(71, 45, 24, .22);
  border-radius: 23px 23px 12px 12px;
  background: rgba(255, 249, 225, .35);
  display: grid;
  place-items: center;
  padding: 2px;
}

.slot button {
  width: 100%; height: 100%; min-height: 50px;
  border: 0; background: transparent; padding: 0; cursor: pointer;
  border-radius: inherit;
}

.slot .flower-svg { width: 48px; height: 55px; transform: rotate(var(--tilt)); }

.take-none {
  min-width: 74px;
  min-height: 44px;
  border: 0;
  background: transparent;
  padding: 7px 8px;
  color: #5f351f;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  white-space: nowrap;
  font-size: 13px;
}

.result {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: var(--eazo-safe-area-top) clamp(14px, 4vw, 28px) var(--eazo-safe-area-bottom);
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,244,186,.48), transparent 26%),
    linear-gradient(180deg, rgba(239, 148, 84, .92), rgba(127, 151, 88, .94));
  overflow-y: auto;
}
.result.show { display: flex; }

.card {
  width: min(720px, 100%);
  max-height: calc(100svh - var(--eazo-safe-area-top) - var(--eazo-safe-area-bottom) - 18px);
  overflow: auto;
  border-radius: 42px 42px 24px 24px;
  border: 2px solid rgba(85, 51, 21, .16);
  background: #fff0cc;
  box-shadow: 0 34px 80px rgba(58, 32, 14, .24);
  padding: clamp(16px, 4vw, 30px);
}

.result-art {
  position: relative;
  height: clamp(185px, 36svh, 330px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 32px;
  background:
    radial-gradient(ellipse at 48% 28%, rgba(255, 222, 126, .52), transparent 42%),
    linear-gradient(180deg, #ffd88a, #f4ba7d 58%, #b4bd78);
}

.wrap {
  position: absolute;
  bottom: 6%; left: 50%;
  transform: translateX(-50%);
  width: min(72%, 360px);
  height: 34%;
  background: #fff8df;
  clip-path: polygon(8% 40%, 50% 100%, 92% 40%, 78% 8%, 22% 8%);
  border: 2px solid rgba(74, 43, 19, .16);
  filter: drop-shadow(0 12px 14px rgba(69, 37, 15, .18));
}

.result-bouquet {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ribbon {
  position: absolute;
  left: 50%; bottom: 21%;
  width: 122px; height: 56px;
  transform: translateX(-50%);
  pointer-events: none;
}
.ribbon path { fill: none; stroke: #d45761; stroke-width: 9; stroke-linecap: round; stroke-dasharray: 260; stroke-dashoffset: 260; animation: tieRibbon 1.05s ease-out forwards; }
.ribbon circle { fill: #d45761; opacity: 0; animation: knot .2s ease .9s forwards; }
@keyframes tieRibbon { to { stroke-dashoffset: 0; } }
@keyframes knot { to { opacity: 1; } }

.sentence {
  margin: 16px 0 8px;
  font-size: clamp(25px, 7vw, 46px);
  line-height: 1.14;
  letter-spacing: -.025em;
  color: #371d12;
  text-align: center;
}

.names {
  margin: 0 auto 14px;
  max-width: 560px;
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
  color: #6d452a;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 0;
}

.action-btn, .details summary {
  min-height: 44px;
  border: 1.5px solid rgba(65, 40, 18, .2);
  border-radius: 999px;
  background: #fbd98b;
  padding: 10px 16px;
  box-shadow: 0 10px 18px rgba(83, 46, 14, .12);
  cursor: pointer;
  white-space: nowrap;
  list-style: none;
}
.action-btn.secondary { background: #f7c4b8; }
.share-note {
  display: none;
  margin: 10px auto 0;
  max-width: 420px;
  padding: 9px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.45);
  text-align: center;
  font-size: 13px;
  color: #5b3420;
}
.share-note.show { display: block; }

.details { margin: 10px auto 0; max-width: 540px; text-align: center; }
.details summary { display: inline-flex; align-items: center; }
.line-list { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; text-align: left; }
.line-list li { padding: 10px 12px; border-radius: 16px; background: rgba(255,255,255,.38); line-height: 1.35; }

.empty .result-art .wrap { height: 40%; }
.empty .ribbon, .empty .result-bouquet { display: none; }

@media (min-width: 760px) {
  .stage { grid-template-rows: minmax(430px, 1fr) auto; }
  .meadow { min-height: 430px; }
  .instruction { grid-column: auto; }
  .top-rail { align-items: center; grid-template-columns: minmax(170px, auto) minmax(0, 1fr) auto; }
  h1 { white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
