:root {
  --paper: #fbf3eb;
  --paper-deep: #f3e6da;
  --ink: #6a4d5a;
  --ink-soft: #8a6b78;
  --blush: #f2c4d4;
  --sky: #c9e4f5;
  --mint: #d5efdf;
  --shadow: rgba(120, 80, 90, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.paper {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 90% 70% at 15% 20%, var(--blush) 0%, transparent 55%),
    radial-gradient(ellipse 80% 60% at 85% 15%, var(--sky) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 70% 85%, var(--mint) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 20% 80%, #f7e2b8 0%, transparent 50%),
    linear-gradient(165deg, #fff9f3 0%, var(--paper) 45%, var(--paper-deep) 100%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.stage {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.5rem, 2vw, 1.25rem);
  padding: clamp(1.5rem, 4vw, 3rem);
  padding-top: max(clamp(1.5rem, 4vw, 3rem), env(safe-area-inset-top));
  padding-bottom: max(clamp(1.5rem, 4vw, 3rem), env(safe-area-inset-bottom));
  text-align: center;
}

.layer {
  position: relative;
  width: min(100%, 420px);
}

.badge-layer {
  width: min(72vw, 280px);
  filter: drop-shadow(0 14px 28px var(--shadow));
}

.wordmark-layer {
  width: min(88vw, 420px);
  margin-top: -0.25rem;
}

.reveal-img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

/* Hidden while canvas paints the reveal; remains drawable as bitmap source */
.reveal-img.is-anim-source {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: auto;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

.reveal-canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
}

.message {
  margin: 1.25rem 0 0;
  max-width: 26rem;
  font-size: clamp(1.05rem, 2.6vw, 1.35rem);
  font-weight: 600;
  line-height: 1.55;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(12px);
}

.message.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.9s ease, transform 0.9s ease;
}

.crayon {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10;
  width: 28px;
  height: 92px;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(2px 4px 6px rgba(90, 60, 70, 0.25));
  will-change: transform, opacity;
  transform-origin: 50% 4%;
}

@media (min-width: 768px) {
  .crayon {
    width: 34px;
    height: 112px;
  }

  .badge-layer {
    width: min(42vw, 320px);
  }

  .wordmark-layer {
    width: min(55vw, 480px);
  }
}

.crayon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.crayon.is-drawing {
  opacity: 1;
  transition: opacity 0.35s ease;
}

.crayon.is-gone {
  opacity: 0;
  transition: opacity 0.5s ease;
}

@media (prefers-reduced-motion: reduce) {
  .crayon {
    display: none !important;
  }

  .message {
    opacity: 1;
    transform: none;
  }

  .reveal-img {
    opacity: 1 !important;
    -webkit-mask-image: none !important;
    mask-image: none !important;
  }
}
