:root {
  --paper: #fff6e9;
  --paper-2: #fdebd3;
  --ink: #2b2140;
  --ink-soft: #5b5170;
  --tomato: #f0533a;
  --tomato-dark: #c93a23;
  --marigold: #f6b31b;
  --teal: #1f9e8f;
  --pink: #f28ab2;
  --cobalt: #3d5bd9;
  --leaf: #8bc34a;
  --white: #fffdf8;
  --radius: 18px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-lg: 6px 6px 0 var(--ink);
  --font-display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --font-body: "Figtree", "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(43, 33, 64, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.01em;
}

p { margin: 0; }

img, svg { display: block; }

/* Text links — clearly styled, accent colored and underlined */
main a:not(.btn), .intro a {
  color: var(--tomato-dark);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: var(--marigold);
  transition: color 0.15s, text-decoration-color 0.15s;
}
main a:not(.btn):hover { color: var(--ink); text-decoration-color: var(--tomato); }

:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; border-radius: 6px; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 50;
  background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; border-radius: 10px;
}
.skip-link:focus { top: 1rem; }

/* ───────── Header ───────── */
.site-header {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-display); font-weight: 800; font-size: 1.3rem;
  color: var(--ink); text-decoration: none;
}
.brand-mark { width: 36px; height: 36px; transition: transform 0.6s cubic-bezier(.2,.8,.2,1); }
.brand:hover .brand-mark { transform: rotate(240deg); }
.site-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.site-nav a {
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.95rem;
  padding: 0.35rem 0.7rem; border-radius: 999px;
}
.site-nav a:hover { background: var(--paper-2); }

/* ───────── Buttons ───────── */
.btn {
  --bg: var(--white);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  font: 700 1rem/1 var(--font-body);
  color: var(--ink); background: var(--bg);
  border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 0.75rem 1.2rem; cursor: pointer; text-decoration: none;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { --bg: var(--tomato); color: var(--ink); }
.btn-primary:hover { --bg: #f4654d; }
.btn-light { --bg: var(--white); }
.btn-lg { font-size: 1.1rem; padding: 0.95rem 1.6rem; }
.btn.is-on { --bg: var(--pink); }
.btn.is-on svg { fill: currentColor; }

/* ───────── Hero ───────── */
.hero {
  max-width: 1160px; margin: 0 auto;
  padding: 2.5rem 1.25rem 3.5rem;
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 2.5rem; align-items: center;
}
.hero h1 {
  font-size: clamp(2.6rem, 6.4vw, 4.9rem);
  font-weight: 800;
  margin-bottom: 1.25rem;
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}
.squiggle {
  color: var(--tomato);
  background: linear-gradient(transparent 72%, var(--marigold) 72% 90%, transparent 90%);
  padding: 0 0.08em;
}
.intro {
  font-size: 1.15rem; max-width: 40rem; color: var(--ink-soft); margin-bottom: 1.75rem;
  animation: rise 0.6s 0.08s cubic-bezier(.2,.8,.2,1) both;
}
.hero-copy .btn { animation: rise 0.6s 0.16s cubic-bezier(.2,.8,.2,1) both; }

.hero-art { position: relative; height: 340px; }
.paper-card {
  position: absolute; width: 230px; padding: 1.1rem 1.2rem 1.4rem;
  background: var(--white); border: 2.5px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 0.6rem;
  font-family: var(--font-display); font-size: 1.3rem;
  animation: drop 0.7s cubic-bezier(.2,.9,.3,1.2) both;
}
.paper-card strong { font-weight: 800; }
.card-a { top: 8px; left: 4%; transform: rotate(-7deg); background: #fff1c8; animation-delay: 0.2s; }
.card-b { top: 110px; right: 2%; transform: rotate(5deg); animation-delay: 0.32s; }
.card-c { bottom: 0; left: 16%; transform: rotate(-2deg); background: #dff3ef; animation-delay: 0.44s; }

.tag {
  display: inline-block; width: fit-content;
  font: 700 0.75rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.4rem 0.6rem; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--white);
}
.tag-yarn { background: var(--pink); }
.tag-paper { background: var(--marigold); }
.tag-clay { background: #f7a07f; }
.tag-fabric { background: #b9c6ff; }
.tag-recycled { background: #bfe3a0; }
.tag-wood { background: #e7c79e; }
.tag-plain { background: var(--paper-2); }

.confetti { position: absolute; width: 18px; height: 18px; border: 2.5px solid var(--ink); }
.c1 { top: 0; right: 18%; background: var(--teal); border-radius: 50%; }
.c2 { top: 46%; left: -2%; background: var(--marigold); transform: rotate(20deg); }
.c3 { bottom: 12%; right: 8%; background: var(--pink); border-radius: 50%; width: 26px; height: 26px; }
.c4 { bottom: 42%; right: 46%; background: var(--cobalt); width: 12px; height: 12px; transform: rotate(45deg); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-30px) rotate(0deg); } }

/* ───────── Sections ───────── */
.spinner, .favorites, .how { max-width: 1160px; margin: 0 auto; padding: 3rem 1.25rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.section-head h2, .how h2, .celebrate h2 { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 800; }
.count-note { font-weight: 700; color: var(--ink-soft); background: var(--white); border: 2px dashed var(--ink-soft); padding: 0.3rem 0.8rem; border-radius: 999px; font-size: 0.9rem; }

.panel {
  background: var(--white); border: 2.5px solid var(--ink); border-radius: 24px;
  box-shadow: var(--shadow-lg); padding: 1.5rem;
}

/* ───────── Spinner ───────── */
.spinner-grid { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: 1.75rem; align-items: start; }

.group { border: 0; padding: 0; margin: 0 0 1.4rem; min-width: 0; }
.group legend { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; margin-bottom: 0.7rem; padding: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.chip {
  --c: var(--paper-2);
  position: relative; display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.55rem 0.95rem 0.55rem 0.75rem; border: 2.5px solid var(--ink); border-radius: 999px;
  font-weight: 700; cursor: pointer; user-select: none; background: var(--white);
  transition: background 0.15s, transform 0.12s, box-shadow 0.12s;
}
.chip svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip:hover { transform: translateY(-1px); }
.chip:has(input:checked) { background: var(--c); box-shadow: 3px 3px 0 var(--ink); }
.chip:has(input:focus-visible) { outline: 3px solid var(--cobalt); outline-offset: 3px; }
.chip.is-checked { background: var(--c); box-shadow: 3px 3px 0 var(--ink); }
.chip-paper { --c: var(--marigold); }
.chip-yarn { --c: var(--pink); }
.chip-clay { --c: #f7a07f; }
.chip-fabric { --c: #b9c6ff; }
.chip-recycled { --c: #bfe3a0; }
.chip-wood { --c: #e7c79e; }

.field-error { margin-top: 0.6rem; color: var(--tomato-dark); font-weight: 700; font-size: 0.95rem; }

.segmented {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border: 2.5px solid var(--ink); border-radius: 14px; overflow: hidden; background: var(--paper);
}
.segmented label { position: relative; cursor: pointer; }
.segmented label + label { border-left: 2.5px solid var(--ink); }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: block; text-align: center; padding: 0.7rem 0.4rem; font-weight: 700; font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}
.segmented input:checked + span { background: var(--ink); color: var(--paper); }
.segmented input:focus-visible + span { outline: 3px solid var(--cobalt); outline-offset: -5px; border-radius: 8px; }
.segmented label:hover span { background: var(--paper-2); }
.segmented label:hover input:checked + span { background: var(--ink); }

.spin-row { display: flex; align-items: center; gap: 1.25rem; margin-top: 0.5rem; }
.wheel { width: 92px; height: 92px; flex: none; }
.wheel-face { transform-origin: 50px 50px; transition: transform 0.9s cubic-bezier(.15,.85,.25,1); }
.btn-spin { flex: 1; font-size: 1.35rem; padding: 1.05rem 1.5rem; font-family: var(--font-display); font-weight: 800; letter-spacing: 0.01em; }
.btn-spin svg { width: 24px; height: 24px; }
.btn-spin[disabled] { opacity: 0.85; cursor: progress; }

/* Result card */
.result { min-height: 420px; position: relative; overflow: hidden; }
.result::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 10px;
  background: repeating-linear-gradient(90deg, var(--tomato) 0 40px, var(--marigold) 40px 80px, var(--teal) 80px 120px, var(--pink) 120px 160px);
  border-bottom: 2.5px solid var(--ink);
}
.result-empty { height: 100%; min-height: 370px; display: grid; place-content: center; justify-items: center; text-align: center; gap: 0.6rem; color: var(--ink-soft); }
.result-empty h3 { color: var(--ink); font-size: 1.5rem; }
.empty-art { width: 130px; margin-bottom: 0.5rem; }

.result-body { padding-top: 0.5rem; }
.result.reveal .result-body { animation: pop 0.45s cubic-bezier(.2,.9,.3,1.25) both; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } }

.result-note { font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); background: var(--paper-2); border-radius: 10px; padding: 0.5rem 0.75rem; margin-bottom: 1rem; }
.result-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.result h3 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 800; margin-bottom: 0.5rem; }
.result-blurb { color: var(--ink-soft); margin-bottom: 1.25rem; }
.result h4 { font: 800 0.85rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 0.6rem; color: var(--teal); }

.supplies { list-style: none; padding: 0; margin: 0 0 1.4rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.supplies li { background: var(--paper); border: 2px solid var(--ink); border-radius: 10px; padding: 0.3rem 0.65rem; font-size: 0.95rem; font-weight: 500; }

.steps { list-style: none; padding: 0; margin: 0 0 1.5rem; counter-reset: step; display: grid; gap: 0.65rem; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 2rem 1fr; gap: 0.7rem; align-items: start; }
.steps li::before {
  content: counter(step); display: grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: 50%; background: var(--marigold); border: 2px solid var(--ink);
  font: 800 0.95rem/1 var(--font-display);
}
.steps li:nth-child(3n+2)::before { background: var(--pink); }
.steps li:nth-child(3n)::before { background: #7fd3c7; }

.result-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; padding-top: 1rem; border-top: 2px dashed rgba(43, 33, 64, 0.25); }

/* ───────── Celebrate ───────── */
.celebrate { position: relative; background: #13756a; color: var(--white); border-block: 2.5px solid var(--ink); margin: 2rem 0; padding: 4.5rem 1.25rem 3.5rem; overflow: hidden; }
.banner-flags { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-around; }
.banner-flags::before { content: ""; position: absolute; top: 10px; left: 0; right: 0; height: 2px; background: var(--ink); }
.banner-flags span {
  position: relative; width: 56px; height: 46px; margin-top: 10px; border: 2.5px solid var(--ink); border-top-width: 0;
  background: var(--marigold);
  clip-path: polygon(0 0, 100% 0, 100% 78%, 88% 100%, 75% 78%, 62% 100%, 50% 78%, 38% 100%, 25% 78%, 12% 100%, 0 78%);
  animation: sway 4s ease-in-out infinite alternate; transform-origin: top center;
}
.banner-flags span:nth-child(4n+2) { background: var(--pink); animation-delay: -1s; }
.banner-flags span:nth-child(4n+3) { background: var(--tomato); animation-delay: -2s; }
.banner-flags span:nth-child(4n) { background: var(--paper); animation-delay: -3s; }
@keyframes sway { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
.celebrate-inner { max-width: 760px; margin: 0 auto; text-align: left; }
.celebrate h2 { margin-bottom: 1rem; }
.celebrate p { font-size: 1.15rem; margin-bottom: 1.5rem; }
.celebrate a:not(.btn) { color: var(--white); text-decoration-color: var(--marigold); text-decoration-thickness: 3px; }
.celebrate a:not(.btn):hover { color: var(--marigold); text-decoration-color: var(--white); }

/* ───────── Favorites ───────── */
.fav-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.fav-item {
  background: var(--white); border: 2.5px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.6rem;
  animation: pop 0.35s cubic-bezier(.2,.9,.3,1.25) both;
}
.fav-item:nth-child(3n+1) { transform: rotate(-0.6deg); }
.fav-item:nth-child(3n+2) { transform: rotate(0.5deg); }
.fav-item h3 { font-size: 1.2rem; }
.fav-meta { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; }
.fav-actions { display: flex; gap: 0.5rem; margin-top: auto; }
.fav-actions .btn { padding: 0.5rem 0.9rem; font-size: 0.9rem; box-shadow: 2px 2px 0 var(--ink); }
.fav-empty {
  display: flex; align-items: center; gap: 1rem; padding: 1.5rem; border: 2.5px dashed var(--ink-soft); border-radius: var(--radius);
  color: var(--ink-soft); background: rgba(255, 253, 248, 0.7);
}
.fav-empty svg { width: 40px; height: 40px; flex: none; fill: var(--pink); stroke: var(--ink); stroke-width: 1.6; }
.fav-empty[hidden] { display: none; }

/* ───────── How it works ───────── */
.how h2 { margin-bottom: 1.75rem; }
.how-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; max-width: 820px; }
.how-steps li { display: grid; grid-template-columns: auto 1fr; gap: 1.1rem; align-items: center; background: var(--white); border: 2.5px solid var(--ink); border-radius: var(--radius); padding: 1rem 1.25rem; }
.how-steps li:nth-child(2) { margin-left: clamp(0rem, 6vw, 4rem); }
.how-steps li:nth-child(3) { margin-left: clamp(0rem, 12vw, 8rem); }
.how-num { display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 50%; border: 2.5px solid var(--ink); font: 800 1.5rem/1 var(--font-display); background: var(--marigold); }
.how-steps li:nth-child(2) .how-num { background: var(--pink); }
.how-steps li:nth-child(3) .how-num { background: #7fd3c7; }
.how-steps h3 { font-size: 1.2rem; margin-bottom: 0.2rem; }
.how-steps p { color: var(--ink-soft); }

/* ───────── Footer ───────── */
.site-footer { margin-top: 2rem; background: var(--ink); color: var(--paper); text-align: center; padding: 2rem 1.25rem; font-weight: 600; }
.site-footer p::before {
  content: ""; display: inline-block; width: 1em; height: 1em; margin-right: 0.45em; vertical-align: -0.15em;
  background: var(--tomato);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-8-5-8-11a4.5 4.5 0 0 1 8-2.8A4.5 4.5 0 0 1 20 10c0 6-8 11-8 11z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-8-5-8-11a4.5 4.5 0 0 1 8-2.8A4.5 4.5 0 0 1 20 10c0 6-8 11-8 11z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ───────── Toast ───────── */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 40;
  transform: translate(-50%, 150%); opacity: 0;
  background: var(--ink); color: var(--paper); font-weight: 700;
  padding: 0.8rem 1.2rem; border-radius: 999px; box-shadow: 3px 3px 0 var(--tomato);
  transition: transform 0.3s cubic-bezier(.2,.9,.3,1.2), opacity 0.3s;
  max-width: calc(100vw - 2rem); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ───────── Responsive ───────── */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 1.5rem; gap: 1.5rem; }
  .hero-art { height: 260px; max-width: 460px; width: 100%; margin: 0 auto; }
  .paper-card { width: 200px; font-size: 1.15rem; }
  .spinner-grid { grid-template-columns: 1fr; }
  .result { min-height: 0; }
  .result-empty { min-height: 220px; }
}

@media (max-width: 600px) {
  body { font-size: 1rem; }
  .site-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; padding-bottom: 0.5rem; }
  .site-nav { margin-left: -0.7rem; }
  .site-nav a { font-size: 0.9rem; padding: 0.3rem 0.6rem; }
  .hero-art { height: 230px; }
  .paper-card { width: 170px; font-size: 1rem; padding: 0.9rem; }
  .card-b { top: 80px; }
  .panel { padding: 1.15rem; border-radius: 20px; }
  .spinner, .favorites, .how { padding: 2rem 1rem; }
  .segmented span { font-size: 0.85rem; padding: 0.65rem 0.2rem; }
  .wheel { width: 72px; height: 72px; }
  .banner-flags span { width: 40px; height: 34px; }
  .banner-flags span:nth-child(n+7) { display: none; }
  .result-actions .btn { flex: 1 1 auto; }
  .fav-empty { flex-direction: column; text-align: center; }
}

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