:root {
  --paper: #fffaf2;
  --desk: #e7d8c6;
  --ink: #3a2a1e;
  --ink-soft: #7a5b48;
  --honey: #f2c56a;
  --line: rgba(74, 52, 38, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "ZCOOL KuaiLe", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background-color: var(--desk);
  background-image:
    radial-gradient(1100px 480px at 50% -8%, rgba(255, 250, 242, 0.95), transparent 62%),
    radial-gradient(700px 420px at 100% 100%, rgba(196, 154, 112, 0.28), transparent 60%);
}

button, input { font: inherit; color: inherit; }

button { -webkit-tap-highlight-color: transparent; }

::selection { background: #f3c9a2; }

.page {
  width: min(1100px, calc(100% - 28px));
  margin: 0 auto;
  padding: 32px 0 72px;
}

.site-header { text-align: center; margin-bottom: 22px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  letter-spacing: 0.08em;
  font-size: 1.05rem;
}

.brand-paw { width: 28px; height: 28px; }

h1, h2 {
  font-family: "Ma Shan Zheng", "Songti SC", cursive;
  font-weight: 400;
  margin: 0;
}

h1 { font-size: clamp(2.3rem, 5vw, 3.5rem); line-height: 1.15; }

.lede {
  max-width: 38rem;
  margin: 10px auto 0;
  line-height: 1.55;
  color: var(--ink-soft);
}

.sheet {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 12px 28px;
  padding: 28px 28px 26px 52px;
  background: var(--paper);
  border-radius: 22px 18px 24px 16px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 16px 40px rgba(80, 55, 35, 0.12);
}

.sheet::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 34px;
  bottom: 34px;
  width: 16px;
  background: radial-gradient(circle at 7px 8px, var(--desk) 5px, transparent 6.5px);
  background-size: 16px 34px;
  pointer-events: none;
}

.preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.preview-frame {
  position: relative;
  width: min(100%, 320px);
  display: grid;
  place-items: center;
  padding-top: 10px;
}

.preview-frame::before {
  content: "";
  position: absolute;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 196, 160, 0.55), rgba(236, 196, 160, 0) 70%);
  z-index: 0;
}

.tape {
  position: absolute;
  top: 2px;
  left: 50%;
  z-index: 2;
  width: 88px;
  height: 22px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(226, 186, 96, 0.62);
  box-shadow: 0 8px 12px rgba(80, 50, 30, 0.05);
}

.draft-mark {
  position: absolute;
  top: 22px;
  right: 0;
  z-index: 2;
  font-family: "Ma Shan Zheng", cursive;
  font-size: 1.35rem;
  color: rgba(196, 83, 62, 0.82);
  transform: rotate(8deg);
}

#bear-preview { position: relative; z-index: 1; }

#bear-preview svg {
  display: block;
  width: min(78vw, 300px);
  height: auto;
  transform: rotate(-2deg);
  transform-origin: 50% 58%;
}

.preview-frame.is-pop svg { animation: bear-pop 0.42s ease; }

@keyframes bear-pop {
  0% { transform: rotate(-2deg) scale(0.94); }
  45% { transform: rotate(1.5deg) scale(1.045); }
  100% { transform: rotate(-2deg) scale(1); }
}

.name-preview {
  font-family: "Ma Shan Zheng", cursive;
  font-size: 2rem;
  line-height: 1.2;
  margin: 2px 0 0;
  min-height: 1.2em;
}

.name-preview.is-placeholder { opacity: 0.42; }

.caption {
  font-family: "Ma Shan Zheng", cursive;
  font-size: 1.55rem;
  margin: 0;
}

.traits {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.45;
}

.designer {
  padding: 4px 0 0 18px;
  border-left: 2px dashed var(--line);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 31px,
    rgba(120, 86, 62, 0.07) 32px
  );
}

.group {
  border: 0;
  margin: 0 0 14px;
  padding: 0;
}

.group legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 1.12rem;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-right: 6px;
  border: 2px solid var(--ink);
  border-radius: 50% 45% 50% 40%;
  font-size: 0.82rem;
  vertical-align: 1px;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice {
  width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 4px 6px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
}

.choice svg {
  width: 84px;
  height: 62px;
  pointer-events: none;
}

.choice span { font-size: 0.92rem; line-height: 1.2; }

.choice:hover { background: rgba(255, 255, 255, 0.55); }

.choice.is-selected {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 2px 2px 0 var(--ink);
}

.choice:focus-visible,
.btn:focus-visible,
input:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 3px;
}

.fields { margin-top: 4px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 1.05rem;
}

.field input {
  width: 100%;
  padding: 4px 2px 6px;
  border: none;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-family: "Ma Shan Zheng", cursive;
  font-size: 1.55rem;
}

.field input::placeholder { color: #b6a090; font-size: 1.2rem; }

.hint {
  margin: 4px 0 12px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.45;
  min-height: 1.3em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.btn {
  cursor: pointer;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.62rem 1.15rem;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 1.08rem;
}

.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }

.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

.btn-primary {
  background: var(--honey);
  font-size: 1.22rem;
  padding: 0.72rem 1.45rem;
}

#result { text-align: center; padding-top: 8px; }

#result .lede { margin-bottom: 6px; }

#result-title { font-size: clamp(2rem, 4vw, 2.8rem); }

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

.card-wrap.is-in { animation: stamp-in 0.48s cubic-bezier(0.2, 1.25, 0.36, 1); }

@keyframes stamp-in {
  0% { transform: scale(1.08) rotate(-1.5deg); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

#card-canvas {
  width: min(100%, 960px);
  height: auto;
  background: #fbf7f0;
  border-radius: 10px;
  box-shadow: 0 18px 46px rgba(70, 45, 25, 0.16);
}

.result-actions { justify-content: center; }

#result .hint { text-align: center; }

.noscript {
  text-align: center;
  padding: 12px;
}

@media (max-width: 800px) {
  .sheet {
    grid-template-columns: 1fr;
    padding: 22px 16px 22px 40px;
  }

  .designer {
    border-left: none;
    border-top: 2px dashed var(--line);
    padding: 16px 0 0;
  }

  .preview-col { position: static; }
}

@media (min-width: 801px) {
  .preview-col {
    position: sticky;
    top: 16px;
    align-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preview-frame.is-pop svg,
  .card-wrap.is-in { animation: none; }

  .btn:hover,
  .btn:active { transform: none; }
}
