:root {
  --paper: #f7f1e8;
  --paper-deep: #eee4d6;
  --ink: #3f4050;
  --muted: #707080;
  --white: #fffdf9;
  --lavender: #8f85ad;
  --lavender-soft: #e9e4f2;
  --lavender-pale: #f4f1f8;
  --sage: #92aa9c;
  --sage-soft: #e4eee8;
  --peach: #dba98f;
  --peach-soft: #f6e5dc;
  --gold: #d6b568;
  --line: #ded5cb;
  --shadow: 0 14px 36px rgba(86, 75, 91, .09);
  --radius-lg: 30px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --max-width: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 3%, rgba(222, 209, 232, .62), transparent 27rem),
    radial-gradient(circle at 95% 28%, rgba(222, 236, 226, .72), transparent 25rem),
    var(--paper);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.65;
}

button, input { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 100;
  padding: 10px 16px; color: white; background: var(--ink); border-radius: 10px;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.page-decor { position: fixed; z-index: -1; color: rgba(143, 133, 173, .22); font-size: 5rem; }
.decor-one { top: 16%; left: 3%; transform: rotate(-12deg); }
.decor-two { right: 4%; bottom: 14%; color: rgba(219, 169, 143, .24); }

.hero {
  width: min(calc(100% - 40px), var(--max-width));
  margin: 36px auto 24px;
  padding: clamp(30px, 6vw, 70px);
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, .65fr);
  align-items: center;
  gap: 32px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 40px;
  background: linear-gradient(135deg, rgba(255,253,249,.94), rgba(243,238,247,.9));
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.hero::after {
  content: ""; position: absolute; width: 320px; height: 320px; border-radius: 50%;
  right: -130px; bottom: -170px; background: rgba(228,238,232,.75);
}
.eyebrow, .section-kicker { margin: 0 0 7px; color: var(--lavender); font-size: .77rem; font-weight: 800; letter-spacing: .18em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 20px; font-size: clamp(2rem, 5vw, 3.75rem); line-height: 1.23; letter-spacing: -.035em; }
.hero-lead { margin-bottom: 10px; font-size: clamp(1.1rem, 2.1vw, 1.35rem); }
.gentle-note { color: var(--muted); font-size: 1rem; }
.hero-art { min-height: 250px; display: grid; place-items: center; position: relative; z-index: 1; }
.dog-portrait {
  width: clamp(175px, 22vw, 235px); aspect-ratio: 1; display: grid; place-items: center;
  position: relative; border: 8px solid rgba(255,255,255,.82); border-radius: 48% 48% 44% 44%;
  background: linear-gradient(150deg, #caa58c, #e2c7b5); box-shadow: 0 18px 40px rgba(107, 77, 60, .15);
}
.ear { position: absolute; top: -16%; width: 37%; height: 56%; z-index: -1; background: #c39a81; border-radius: 80% 30% 30% 25%; }
.ear-left { left: 2%; transform: rotate(-25deg); }
.ear-right { right: 2%; transform: scaleX(-1) rotate(-25deg); }
.dog-face { font-family: Georgia, serif; font-size: clamp(2.6rem, 6vw, 4rem); color: #4d3d3c; letter-spacing: .08em; }
.doodle { position: absolute; font-size: 1.8rem; }
.paw-one { left: 0; bottom: 8%; transform: rotate(-18deg); opacity: .6; }
.star-one { top: 3%; right: 3%; color: var(--gold); }
.heart-one { right: -2%; bottom: 17%; color: var(--peach); font-size: 2.5rem; }

.button {
  min-height: 58px; padding: 14px 24px; border: 0; border-radius: 18px;
  font-weight: 800; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-2px); }
.button:focus-visible, .icon-button:focus-visible, .text-button:focus-visible, .mini-nav a:focus-visible, .option-card:has(input:focus-visible) {
  outline: 3px solid rgba(143,133,173,.4); outline-offset: 3px;
}
.button-random { margin-top: 10px; background: var(--ink); color: white; box-shadow: 0 10px 22px rgba(63,64,80,.18); }
.button-primary { background: var(--lavender); color: white; }
.button-secondary { background: var(--lavender-soft); color: #554f67; }
.button-draw { width: 100%; min-height: 70px; margin-top: 28px; color: white; background: linear-gradient(135deg, var(--lavender), #7a7597); font-size: 1.12rem; box-shadow: 0 13px 26px rgba(116,108,144,.2); }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; }

.random-panel {
  width: min(calc(100% - 40px), var(--max-width)); margin: 0 auto 24px; padding: clamp(24px, 4vw, 38px);
  border: 2px solid rgba(143,133,173,.28); border-radius: var(--radius-lg); background: var(--white); box-shadow: var(--shadow);
}
.random-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.random-heading h2 { margin-bottom: 8px; font-size: clamp(1.45rem, 3vw, 2rem); }
.icon-button { width: 48px; height: 48px; flex: 0 0 auto; border: 0; border-radius: 50%; background: var(--lavender-pale); cursor: pointer; font-size: 1.7rem; line-height: 1; }
.random-result { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.random-result span { padding: 9px 14px; border-radius: 999px; background: var(--sage-soft); font-weight: 700; }
.small-note { color: var(--muted); }

.mini-nav {
  position: sticky; top: 10px; z-index: 20;
  width: min(calc(100% - 40px), 720px); margin: 0 auto 32px; padding: 8px;
  display: flex; justify-content: center; gap: 4px;
  border: 1px solid rgba(222,213,203,.85); border-radius: 20px;
  background: rgba(255,253,249,.86); box-shadow: 0 7px 22px rgba(70,64,78,.08); backdrop-filter: blur(14px);
}
.mini-nav a { min-height: 48px; padding: 10px 14px; display: flex; align-items: center; gap: 5px; color: var(--ink); text-decoration: none; border-radius: 14px; font-weight: 750; }
.mini-nav a:hover { background: var(--lavender-pale); }

main { width: min(calc(100% - 40px), var(--max-width)); margin: 0 auto; }
.design-section {
  scroll-margin-top: 92px; margin-bottom: 28px; padding: clamp(26px, 5vw, 48px);
  border: 1px solid rgba(222,213,203,.84); border-radius: var(--radius-lg); background: rgba(255,253,249,.92); box-shadow: var(--shadow);
}
.section-heading { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 28px; }
.section-number { min-width: 45px; padding-top: 5px; color: var(--peach); border-top: 2px solid var(--peach); font-size: .8rem; font-weight: 900; letter-spacing: .1em; }
.section-heading h2 { margin-bottom: 4px; font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1.35; }
.section-heading p, .selection-guide { margin-bottom: 0; color: var(--muted); }
.selection-guide { margin: -12px 0 20px 63px; padding: 10px 15px; display: inline-block; border-radius: 12px; background: var(--peach-soft); }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.choice-group + .choice-group { margin-top: 34px; padding-top: 30px; border-top: 1px dashed var(--line); }
.choice-group legend { margin-bottom: 16px; font-size: 1.08rem; font-weight: 850; }
.choice-group legend span { width: 30px; height: 30px; margin-right: 8px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--sage-soft); color: #557062; }
.option-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.compact-grid, .accessory-grid, .role-grid, .personality-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.option-card {
  min-height: 120px; padding: 18px; position: relative; display: flex; flex-direction: column; justify-content: center;
  border: 2px solid transparent; border-radius: var(--radius-md); background: #faf8f4; cursor: pointer; user-select: none;
  transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}
.option-card:hover { transform: translateY(-2px); border-color: rgba(143,133,173,.25); }
.option-card input { position: absolute; opacity: 0; pointer-events: none; }
.option-card strong { font-size: 1.06rem; line-height: 1.4; }
.option-card small { margin-top: 7px; color: var(--muted); line-height: 1.45; }
.option-card .check {
  width: 28px; height: 28px; position: absolute; top: 10px; right: 10px; display: grid; place-items: center;
  border-radius: 50%; color: white; background: var(--lavender); opacity: 0; transform: scale(.7); transition: .16s ease;
}
.option-card:has(input:checked) { border-color: var(--lavender); background: var(--lavender-soft); box-shadow: 0 7px 16px rgba(116,108,144,.1); }
.option-card:has(input:checked) .check { opacity: 1; transform: scale(1); }
.option-card.compact { min-height: 74px; padding: 16px 42px 16px 15px; }
.color-dot { width: 20px; height: 20px; margin-bottom: 5px; display: inline-block; border: 1px solid rgba(63,64,80,.18); border-radius: 50%; }
.color-dot.white { background: white; }
.color-dot.black { background: #34343a; }
.color-dot.brown { background: #966f55; }
.color-dot.yellow { background: #e2c273; }
.color-dot.gray { background: #a5a5aa; }
.color-dot.split-bw { background: linear-gradient(90deg, #34343a 50%, white 50%); }
.color-dot.split-br { background: linear-gradient(90deg, #966f55 50%, white 50%); }

.custom-input { margin-top: 18px; padding: 20px; border-radius: var(--radius-md); background: var(--sage-soft); }
.custom-input label { display: block; margin-bottom: 8px; font-weight: 800; }
.custom-input input {
  width: min(100%, 560px); min-height: 56px; padding: 12px 16px; border: 2px solid transparent; border-radius: 14px;
  color: var(--ink); background: white;
}
.custom-input input:focus { outline: none; border-color: var(--sage); }
.friendly-alert { min-height: 0; margin: 16px 0 0; color: #625c76; font-weight: 800; }
.friendly-alert:not(:empty) { padding: 12px 16px; border-radius: 14px; background: var(--lavender-soft); }

.summary-card, .final-card {
  scroll-margin-top: 92px; margin: 42px 0 28px; padding: clamp(28px, 6vw, 58px);
  border-radius: 36px; background: linear-gradient(145deg, #4c4c5c, #3e3f4d); color: white; box-shadow: 0 20px 44px rgba(52,51,62,.2);
}
.summary-title { display: flex; align-items: center; gap: 17px; margin-bottom: 28px; }
.summary-title h2 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.5rem); }
.summary-title .section-kicker { color: #d8cdec; }
.summary-dog { width: 68px; height: 68px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 22px; background: rgba(255,255,255,.11); font-size: 2rem; }
.summary-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.summary-row { padding: 17px; border: 1px solid rgba(255,255,255,.11); border-radius: 18px; background: rgba(255,255,255,.07); }
.summary-row:first-child { grid-column: 1 / -1; }
.summary-row h3 { margin-bottom: 10px; color: #d8d2e3; font-size: .86rem; letter-spacing: .08em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 11px; border-radius: 999px; color: #41414d; background: #f7f0e5; font-weight: 800; }
.chip.empty { color: #d5d2dc; background: rgba(255,255,255,.09); font-weight: 600; }

.final-card { position: relative; overflow: hidden; text-align: center; background: linear-gradient(140deg, #716c8c, #505266); }
.final-card::before { content: ""; position: absolute; inset: 16px; pointer-events: none; border: 1px solid rgba(255,255,255,.18); border-radius: 26px; }
.final-sparkles { color: #f1d8a0; letter-spacing: .5em; }
.final-card .section-kicker { margin-top: 12px; color: #ddd5ed; }
.final-card h2 { font-size: clamp(1.7rem, 4vw, 2.65rem); }
.final-profile { width: min(100%, 770px); margin: 24px auto; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; text-align: left; }
.final-profile .profile-row { padding: 16px 18px; border-radius: 17px; background: rgba(255,255,255,.1); }
.final-profile strong { display: block; margin-bottom: 4px; color: #ded8eb; font-size: .82rem; letter-spacing: .06em; }
.final-profile span { font-size: 1.08rem; font-weight: 800; }
.drawing-message { margin: 30px 0; }
.drawing-message p { margin-bottom: 4px; color: #eceaf0; }
.drawing-message strong { margin-top: 20px; display: block; font-size: clamp(1.15rem, 3vw, 1.45rem); }
.final-card .button-secondary { position: relative; }

.reset-area { padding: 22px 0 58px; text-align: center; }
.text-button { min-height: 44px; padding: 8px 15px; border: 0; border-bottom: 1px solid var(--muted); background: transparent; color: var(--muted); cursor: pointer; }
.reset-area p { margin-top: 10px; color: #8b8991; font-size: .85rem; }
footer { width: min(calc(100% - 40px), var(--max-width)); margin: 0 auto 35px; display: flex; justify-content: space-between; color: var(--muted); }
footer a { color: inherit; }

@media (max-width: 930px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { min-height: 220px; }
  .option-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .compact-grid, .accessory-grid, .role-grid, .personality-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
  .hero, main, .random-panel, .mini-nav, footer { width: min(calc(100% - 24px), var(--max-width)); }
  .hero { margin-top: 12px; padding: 28px 23px; border-radius: 28px; }
  .hero-art { min-height: 185px; }
  .mini-nav { top: 6px; justify-content: space-around; overflow-x: auto; }
  .mini-nav a { padding: 8px 10px; flex-direction: column; gap: 0; font-size: .78rem; white-space: nowrap; }
  .design-section { padding: 26px 18px; border-radius: 24px; }
  .section-heading { gap: 12px; }
  .section-number { min-width: 36px; }
  .selection-guide { margin-left: 0; }
  .option-grid, .compact-grid, .accessory-grid, .role-grid, .personality-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .option-card { min-height: 106px; padding: 14px 38px 14px 14px; }
  .option-card.compact { min-height: 68px; padding: 13px 36px 13px 13px; }
  .option-card strong { font-size: .96rem; }
  .option-card small { font-size: .8rem; }
  .option-card .check { width: 25px; height: 25px; right: 8px; top: 8px; }
  .summary-card, .final-card { padding: 28px 18px; border-radius: 27px; }
  .summary-list, .final-profile { grid-template-columns: 1fr; }
  .summary-row:first-child { grid-column: auto; }
  .button-row .button { flex: 1 1 140px; }
}

@media (max-width: 380px) {
  .mini-nav a span { display: none; }
  .mini-nav a { font-size: 1.1rem; }
  .option-grid, .compact-grid, .accessory-grid, .role-grid, .personality-grid { grid-template-columns: 1fr; }
  .option-card, .option-card.compact { min-height: 66px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
