:root {
  --bg-from: #e7eef5;
  --bg-to: #cfdce8;
  --accent: #1e3a4c;
  --accent-soft: #3d7a8c;
  --surface: rgba(255, 255, 255, 0.82);
  --ink: #1a2833;
  --muted: #5a6d7a;
  --line: rgba(30, 58, 76, 0.12);
  --shadow: 0 18px 48px rgba(26, 40, 51, 0.12);
  --radius: 28px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --hero-gallery-from: color-mix(in srgb, var(--bg-from) 72%, white);
  --hero-gallery-to: color-mix(in srgb, var(--bg-to) 55%, var(--accent-soft));
  --hero-gallery-shadow: rgba(26, 40, 51, 0.12);
  --on-accent: #f4f8fb;
  --on-accent-muted: rgba(244, 248, 251, 0.82);
  --footer-fg: color-mix(in srgb, var(--ink) 72%, var(--muted));
  --ghost-bg: color-mix(in srgb, var(--accent) 10%, white);
  --ghost-fg: color-mix(in srgb, var(--accent) 88%, var(--ink));
  --ghost-bg-on-surface: color-mix(in srgb, var(--accent) 10%, white);
  --ghost-fg-on-surface: color-mix(in srgb, var(--accent) 88%, var(--ink));
  --disclaimer-bg: color-mix(in srgb, var(--ink) 6%, white);
  --disclaimer-fg: color-mix(in srgb, var(--ink) 68%, var(--muted));
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(61, 122, 140, 0.18), transparent 36%),
    radial-gradient(circle at 88% 12%, rgba(30, 58, 76, 0.12), transparent 32%),
    linear-gradient(180deg, var(--bg-from) 0%, var(--bg-to) 100%);
  background-attachment: fixed;
}

button {
  font: inherit;
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 28px 18px 40px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.shell {
  width: 100%;
  max-width: 440px;
}

.screen {
  display: none;
  animation: rise 0.45s var(--ease);
}

.screen.is-active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.tag {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #f4f8fb;
  font-size: 12px;
  letter-spacing: 0.04em;
  margin-bottom: 16px;
}

.hero-visual {
  height: 132px;
  border-radius: 22px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.28) 0 10%, transparent 11%),
    linear-gradient(135deg, var(--accent) 0%, var(--accent-soft) 55%, #8fb4c0 100%);
}

.hero-visual.has-gallery,
.hero-visual.has-animals {
  height: auto;
  min-height: 148px;
  padding: 14px;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.35), transparent 42%),
    linear-gradient(145deg, var(--hero-gallery-from) 0%, var(--hero-gallery-to) 48%, color-mix(in srgb, var(--accent-soft) 82%, var(--accent)) 100%);
}

.hero-visual.has-gallery::after,
.hero-visual.has-animals::after {
  color: color-mix(in srgb, var(--accent) 38%, transparent);
  left: auto;
  right: 12px;
  bottom: 8px;
}

.hero-visual::after {
  content: attr(data-watermark);
  position: absolute;
  left: 18px;
  bottom: 16px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  letter-spacing: 0.18em;
}

.hero-gallery,
.hero-animals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 8px;
  justify-items: stretch;
  align-items: start;
  width: 100%;
  position: relative;
  z-index: 1;
}

.hero-gallery[data-count="4"],
.hero-animals[data-count="4"] {
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.hero-gallery[data-count="4"] .hero-gallery-item figcaption,
.hero-gallery[data-count="4"] .hero-animal figcaption,
.hero-animals[data-count="4"] .hero-gallery-item figcaption,
.hero-animals[data-count="4"] .hero-animal figcaption {
  font-size: 10px;
}

.hero-gallery[data-count="4"] .hero-image-frame,
.hero-animals[data-count="4"] .hero-image-frame {
  border-radius: 12px;
}

.hero-gallery[data-count="8"],
.hero-animals[data-count="8"] {
  grid-template-columns: repeat(6, 1fr);
  gap: 10px 8px;
}

.hero-gallery[data-count="8"] .hero-gallery-item,
.hero-gallery[data-count="8"] .hero-animal,
.hero-animals[data-count="8"] .hero-gallery-item,
.hero-animals[data-count="8"] .hero-animal {
  grid-column: span 2;
}

.hero-gallery[data-count="8"] .hero-gallery-item:nth-child(7),
.hero-gallery[data-count="8"] .hero-animal:nth-child(7),
.hero-animals[data-count="8"] .hero-gallery-item:nth-child(7),
.hero-animals[data-count="8"] .hero-animal:nth-child(7) {
  grid-column: 2 / span 2;
}

.hero-gallery[data-count="8"] .hero-gallery-item:nth-child(8),
.hero-gallery[data-count="8"] .hero-animal:nth-child(8),
.hero-animals[data-count="8"] .hero-gallery-item:nth-child(8),
.hero-animals[data-count="8"] .hero-animal:nth-child(8) {
  grid-column: 4 / span 2;
}

.hero-gallery[data-count="8"] .hero-gallery-item figcaption,
.hero-gallery[data-count="8"] .hero-animal figcaption,
.hero-animals[data-count="8"] .hero-gallery-item figcaption,
.hero-animals[data-count="8"] .hero-animal figcaption {
  font-size: 10px;
}

.hero-gallery[data-count="8"] .hero-image-frame,
.hero-animals[data-count="8"] .hero-image-frame {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
}

.hero-gallery-item,
.hero-animal {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-width: 0;
  margin: 0;
  text-align: center;
}

.hero-image-frame {
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 8px 18px var(--hero-gallery-shadow);
}

.hero-image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  transform: translate(var(--portrait-x, 0), var(--portrait-y, 0)) scale(var(--portrait-zoom, 1));
  transform-origin: center;
}

.hero-gallery-item figcaption,
.hero-animal figcaption {
  width: 100%;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
  color: var(--accent);
  letter-spacing: 0.02em;
  font-weight: 650;
}

.hero-hint {
  margin: -10px 0 18px;
  text-align: center;
  font-size: 12px;
  color: var(--accent-soft);
  letter-spacing: 0.02em;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(26px, 7vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.lead {
  margin: 0 0 22px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--muted);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.meta-chip {
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(30, 58, 76, 0.06);
  color: var(--accent);
  font-size: 13px;
}

.btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 15px 18px;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.18s var(--ease), opacity 0.18s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #f4f8fb;
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: var(--ghost-bg);
  color: var(--ghost-fg);
}

/* Card surface stays light even on dark page themes — ghost must follow ink/accent, not page tone. */
.card .btn-ghost {
  background: var(--ghost-bg-on-surface);
  color: var(--ghost-fg-on-surface);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.progress {
  height: 8px;
  border-radius: 99px;
  background: rgba(30, 58, 76, 0.1);
  overflow: hidden;
  margin-bottom: 22px;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-soft));
  transition: width 0.35s var(--ease);
}

.question-text {
  margin: 0 0 20px;
  font-size: 21px;
  line-height: 1.45;
  font-weight: 650;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  padding: 14px 14px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.option:hover {
  border-color: rgba(30, 58, 76, 0.28);
}

.option.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #f4f8fb;
  box-shadow: 0 10px 24px rgba(30, 58, 76, 0.22);
}

.option-key {
  display: inline-block;
  min-width: 1.4em;
  font-weight: 700;
  opacity: 0.72;
  margin-right: 6px;
}

.nav {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.nav .btn {
  flex: 1;
}

.result-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 28px 22px;
  margin-bottom: 14px;
  color: var(--on-accent);
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-soft) 62%, color-mix(in srgb, var(--accent-soft) 70%, var(--bg-to)) 100%);
  box-shadow: var(--shadow);
}

.result-hero.has-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 24px;
}

.result-hero::before {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  right: -40px;
  top: -40px;
}

.result-hero::after {
  content: attr(data-watermark);
  position: absolute;
  right: 18px;
  bottom: 16px;
  font-size: 10px;
  letter-spacing: 0.16em;
  opacity: 0.45;
}

.result-label {
  display: inline-block;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  margin-bottom: 12px;
}

.result-label.is-egg {
  background: rgba(255, 244, 214, 0.28);
  margin-right: 6px;
}

.result-image {
  display: block;
  width: min(100%, 280px);
  max-height: min(52vw, 360px);
  aspect-ratio: 3 / 4;
  object-fit: contain;
  object-position: center;
  border-radius: 20px;
  margin: 4px auto 16px;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 28px rgba(26, 40, 51, 0.18);
  position: relative;
  z-index: 1;
}

.result-hero h1 {
  color: inherit;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.22);
}

.score-line {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--on-accent-muted);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.18);
}

.result-secondary {
  display: inline-flex;
  margin: -2px 0 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(244, 248, 251, 0.9);
  font-size: 12px;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

.result-sub {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--on-accent-muted);
  max-width: 92%;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.18);
}

.result-hero.has-image .result-sub {
  max-width: 100%;
}

.section-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.body-copy {
  margin: 0;
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
}

.list {
  margin: 0;
  padding-left: 1.1em;
  display: grid;
  gap: 8px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}

.quote {
  margin: 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent-soft);
  background: rgba(61, 122, 140, 0.08);
  border-radius: 0 14px 14px 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--accent);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.disclaimer {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--disclaimer-bg);
  color: var(--disclaimer-fg);
  font-size: 12px;
  line-height: 1.65;
}

.footer-note {
  margin-top: 16px;
  text-align: center;
  color: var(--footer-fg);
  font-size: 12px;
  line-height: 1.6;
}

body[data-theme-tone="light"] .btn-ghost {
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

body[data-theme-tone="dark"] {
  --footer-fg: rgba(255, 255, 255, 0.78);
  --ghost-bg: rgba(255, 255, 255, 0.16);
  --ghost-fg: rgba(255, 255, 255, 0.94);
  --disclaimer-bg: rgba(255, 255, 255, 0.1);
  --disclaimer-fg: rgba(255, 255, 255, 0.82);
  --hero-gallery-shadow: rgba(0, 0, 0, 0.22);
}

body[data-theme-tone="dark"] .meta-chip {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.88);
}

.error-box {
  padding: 20px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #e8b4b4;
  color: #8a3030;
  line-height: 1.6;
}

.lead-pre {
  white-space: pre-line;
}

.result-nickname {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--on-accent-muted);
  position: relative;
  z-index: 1;
}

.result-keyword {
  display: inline-block;
  margin: 0 0 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--on-accent);
  font-size: 13px;
  position: relative;
  z-index: 1;
}

.score-line.is-percent {
  font-size: 22px;
  font-weight: 700;
  color: var(--on-accent);
}

.dimension-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.dimension-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--ink);
}

.dimension-list .stars {
  letter-spacing: 0.12em;
  color: var(--accent);
}

.reveal-card {
  min-height: 42vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.reveal-text {
  margin: 0;
  font-size: clamp(20px, 6vw, 28px);
  line-height: 1.6;
  font-weight: 700;
  white-space: pre-line;
}

.share-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 10, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.share-modal[hidden] {
  display: none;
}

.share-dialog {
  width: min(100%, 440px);
  max-height: 92vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.share-dialog canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  margin: 10px 0 14px;
  background: #fff;
}

.share-status {
  margin: 0 0 12px;
  font-size: 12px;
  word-break: break-all;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(30, 20, 20, 0.88);
  color: #fff;
  font-size: 13px;
  z-index: 50;
}

.option:focus-visible,
.btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, white);
  outline-offset: 2px;
}
