*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-1);
  line-height: 1.45;
  min-height: 100%;
}
body { display: flex; justify-content: center; }
.app {
  width: 100%;
  max-width: var(--max);
  min-height: 100dvh;
  padding: calc(var(--space) * 2);
  padding-bottom: calc(var(--space) * 4);
  position: relative;
}
h1 { font-size: var(--fs-3); margin: 0 0 var(--space); line-height: 1.2; }
h2 { font-size: var(--fs-2); margin: 0 0 var(--space); }
h3 { font-size: var(--fs-1); margin: 0 0 var(--space); }
p { margin: 0 0 calc(var(--space) * 1.5); }
a { color: var(--gold-text); }
.glance { font-size: var(--fs-0); color: var(--gold-text); margin-bottom: calc(var(--space) * 2); }
.header-bar {
  background: var(--plum-deep);
  color: var(--cream);
  margin: calc(var(--space) * -2) calc(var(--space) * -2) calc(var(--space) * 2);
  padding: calc(var(--space) * 2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.header-bar a { color: var(--gold); }
.brand { font-weight: 700; font-size: var(--fs-1); letter-spacing: 0.02em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); min-width: var(--tap);
  padding: 0 calc(var(--space) * 2);
  border-radius: var(--radius);
  border: 2px solid transparent;
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--pumpkin); color: var(--ink); }
.btn-primary:not(:disabled):hover { filter: brightness(1.05); }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--plum); }
.btn-ghost { background: transparent; color: var(--cream); border-color: rgba(251,247,240,0.35); }
.btn-block { width: 100%; }
@media (prefers-reduced-motion: reduce) {
  .btn, .sparkle, * { transition: none !important; animation: none !important; }
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: calc(var(--space) * 2);
  border: 1px solid rgba(31,36,48,0.06);
}
.card:focus-visible, .cat-card:focus-visible, .costume-card:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}

.age-gate { display: flex; flex-direction: column; gap: calc(var(--space) * 2); padding-top: calc(var(--space) * 6); }
.age-gate .hero { font-size: var(--fs-3); font-weight: 700; line-height: 1.15; }
.check-row {
  display: flex; gap: var(--space); align-items: flex-start;
  min-height: var(--tap); padding: var(--space) 0;
}
.check-row input {
  width: 24px; height: 24px; margin-top: 2px; flex-shrink: 0;
  accent-color: var(--pumpkin);
}
.search {
  width: 100%; min-height: var(--tap);
  border: 2px solid rgba(31,36,48,0.15);
  border-radius: var(--radius);
  padding: 0 calc(var(--space) * 2);
  font: inherit; background: var(--white); color: var(--ink);
  margin-bottom: calc(var(--space) * 2);
}
.search:focus { border-color: var(--gold); outline: none; }

.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--space) * 1.5);
}
.cat-card, .costume-card {
  display: flex; flex-direction: column; gap: var(--space);
  text-decoration: none; color: inherit; cursor: pointer;
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  border: none; padding: 0; text-align: left; font: inherit;
  min-height: var(--tap);
}
.cat-card img, .costume-card img, .preview-img {
  width: 100%; aspect-ratio: 4/5; object-fit: cover; background: var(--plum-deep); display: block;
}
.costume-card-art {
  position: relative;
  width: 100%;
}
.costume-card-art img {
  width: 100%; aspect-ratio: 4/5; object-fit: cover; background: var(--plum-deep); display: block;
}
.card-emoji, .emoji-overlay {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 32px;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.cat-card .meta, .costume-card .meta { padding: var(--space) calc(var(--space) * 1.5) calc(var(--space) * 1.5); }
.chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--warn-bg); color: var(--ink);
  margin-right: 4px;
}
.chip-plum { background: var(--plum); color: var(--cream); }
.chip-ok { background: var(--ok); color: var(--white); }

.pieces { list-style: none; padding: 0; margin: 0 0 calc(var(--space) * 2); }
.pieces li {
  display: flex; align-items: center; gap: var(--space);
  min-height: var(--tap); padding: var(--space) 0;
  border-bottom: 1px solid rgba(31,36,48,0.08);
}
.pieces input { width: 22px; height: 22px; accent-color: var(--ok); }
.steps { padding-left: 1.25rem; margin: 0 0 calc(var(--space) * 2); }
.steps li { margin-bottom: var(--space); }

.footer {
  margin-top: calc(var(--space) * 4);
  padding-top: calc(var(--space) * 2);
  border-top: 1px solid rgba(31,36,48,0.1);
  font-size: var(--fs-0);
  display: flex; flex-wrap: wrap; gap: calc(var(--space) * 1.5);
}
.footer a { color: var(--gold-text); }

.ad-slot {
  min-height: 0;
  margin: calc(var(--space) * 2) 0;
  border-radius: var(--radius);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: rgba(31,36,48,0.35);
}
.ad-slot[data-ads-enabled="true"] { min-height: 90px; background: rgba(31,36,48,0.04); }
.ad-slot.collapsed { display: none; height: 0; margin: 0; min-height: 0; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(31,36,48,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 40; padding: calc(var(--space) * 2);
}
.modal {
  background: var(--cream); color: var(--ink);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: calc(var(--space) * 2);
  width: 100%; max-width: var(--max);
  max-height: 90dvh; overflow: auto;
  box-shadow: var(--shadow);
}
.preview-stage {
  position: relative; width: 100%; aspect-ratio: 4/5;
  background: var(--plum-deep); border-radius: var(--radius); overflow: hidden;
}
.preview-stage canvas, .preview-stage img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.preview-actions {
  display: flex; flex-wrap: wrap; gap: var(--space);
  margin-top: calc(var(--space) * 2);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hidden { display: none !important; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--plum-deep); color: var(--cream);
  padding: 12px 16px; border-radius: var(--radius); z-index: 50;
  max-width: min(360px, 92vw); font-size: var(--fs-0);
}
.sparkle {
  pointer-events: none; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(201,151,58,0.45), transparent 55%);
  opacity: 0; animation: sparkle 280ms ease forwards;
}
@keyframes sparkle { 0% { opacity: 0; } 40% { opacity: 1; } 100% { opacity: 0; } }

.cookie-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; pointer-events: none;
}
.cookie-banner .inner {
  pointer-events: auto;
  width: 100%; max-width: var(--max);
  background: var(--plum-deep); color: var(--cream);
  padding: calc(var(--space) * 2);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: var(--fs-0);
  box-shadow: var(--shadow);
}
/* DR-6: reserve space so fixed banner never covers preview (or other) action CTAs */
body.has-cookie-banner {
  --cookie-banner-reserve: 132px;
}
body.has-cookie-banner #app {
  padding-bottom: calc(var(--cookie-banner-reserve) + 16px);
}
body.has-cookie-banner .preview-actions {
  margin-bottom: calc(var(--cookie-banner-reserve) + 8px);
  scroll-margin-bottom: calc(var(--cookie-banner-reserve) + 24px);
}
.header-back-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 4px;
}
.btn-back-icon {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 44px;
  min-width: 44px;
  padding: 0 8px 0 0;
  margin: 0;
  background: none;
  border: none;
  color: var(--gold-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.btn-back-icon:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.header-brand-row, .brand-row {
  display: flex;
  align-items: center;
}
.header-title {
  color: #FBF7F0;
  font-size: 21.88px;
  margin: 8px 0 0;
}
.back {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; color: var(--gold-text);
  text-decoration: none; font-weight: 600; background: none; border: none;
  font: inherit; cursor: pointer; padding: 0;
}
.error-page { padding-top: calc(var(--space) * 6); text-align: center; }
.legal { max-width: var(--max); margin: 0 auto; padding: calc(var(--space) * 2); }
.legal h1 { margin-top: calc(var(--space) * 2); }

.brand-btn{background:none;border:0;color:inherit;font:inherit;font-weight:700;cursor:pointer;padding:8px 0;text-align:left;min-height:44px;display:inline-flex;align-items:center}
.overlay-stage{border-radius:12px}
.preview-actions{display:flex;flex-wrap:wrap;gap:8px;margin:12px 0}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}

/* rc4 — house ads, badges, share card, email panel, trending */
.ad-slot.house-ad {
  min-height: auto;
  margin: calc(var(--space) * 2) 0;
  background: linear-gradient(135deg, rgba(224,122,47,0.12), rgba(42,33,72,0.08));
  border: 1px dashed rgba(224,122,47,0.55);
  padding: calc(var(--space) * 1.5);
  display: block;
}
.house-ad-inner { text-align: left; color: var(--ink); }
.house-ad-kicker {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pumpkin);
  margin-bottom: 4px;
}
.house-ad-inner p { margin: 0; font-size: var(--fs-0); }
.chip-time { background: rgba(42,33,72,0.08); color: var(--ink); }
.trending-strip {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: calc(var(--space) * 2);
}
.trending-label { font-size: var(--fs-0); color: var(--gold-text); font-weight: 600; margin-right: 4px; }
.share-card-panel, .email-results-panel { margin-top: calc(var(--space) * 2); }
.email-results-panel .newsletter-row label { font-size: var(--fs-0); }
.footer-more {
  flex-basis: 100%;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 4px;
}
.footer-more-label { color: var(--ink); font-weight: 600; }
.ai-signage { flex-basis: 100%; margin: 4px 0 0; opacity: 0.85; }
.coming-soon { font-style: italic; }

/* --- rc5 DesignerBot DR-3/4/7/8 --- */
.overlay-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
}
.overlay-ctrl {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  font-size: 1.1rem;
  line-height: 1;
}
.preview-more {
  width: 100%;
}
.preview-more > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.preview-more > summary::-webkit-details-marker { display: none; }
/* Author display:flex must not override UA hide for closed <details> */
.preview-more:not([open]) > .preview-more-body {
  display: none;
}
.preview-more[open] > .preview-more-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(201, 151, 58, 0.18);
  color: var(--ink);
  font-size: var(--fs-0);
  font-weight: 600;
  border: 1px solid rgba(201, 151, 58, 0.45);
}
.badge-budget {
  background: rgba(232, 140, 48, 0.2);
  border-color: rgba(232, 140, 48, 0.55);
}
/* DR-4: footer / brand tap targets ≥44px */
.footer a,
.footer-more a,
.site-brand,
.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
/* DR-8: reserve clearance when third-party ads are enabled */
.ad-slot[data-ads-enabled="true"] {
  min-height: 56px;
  margin-bottom: 8px;
}
.preview-stage,
.overlay-stage {
  margin-bottom: 0;
}
body.ads-layout-pad .app-main,
#app.ads-layout-pad {
  padding-bottom: 56px;
}

/* rc6: quick start + pieces owned/buy */
.quick-start-promo { margin: 12px 0 16px; padding: 14px 16px; }
.quick-start h2 { font-size: 1rem; margin: 14px 0 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip-selected { outline: 2px solid var(--accent, #E07A2F); background: rgba(224,122,47,.2); }
.quick-pick { margin: 12px 0; }
.quick-pick .btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1 1 auto; min-width: 96px; }
.pieces .piece-row { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0; }
.pieces label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip-need { font-size: .7rem; text-transform: uppercase; letter-spacing: .02em; }
.chip-owned { background: #2d5a3d; color: #c8f0d4; }
.chip-buy { background: #5a3a2d; color: #f0d4c8; }
.chip-band { font-size: .7rem; opacity: .9; }
.pieces-compact li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0; list-style: none; }
.pieces-compact { padding-left: 0; }
