:root {
  --bg-a: #fff8fb;
  --bg-b: #edf8ff;
  --ink: #2c2430;
  --muted: #746a79;
  --card: rgba(255, 255, 255, 0.88);
  --line: rgba(44, 36, 48, 0.12);
  --accent: #ff7aa8;
  --accent-2: #65c7c1;
  --shadow: 0 18px 50px rgba(74, 54, 82, 0.16);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 12%, rgba(255, 195, 218, 0.48), transparent 28rem),
    radial-gradient(circle at 88% 14%, rgba(153, 224, 214, 0.42), transparent 24rem),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));
}

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

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 16px 32px;
  display: grid;
  align-items: center;
}

.screen {
  display: none;
  animation: screenIn 360ms ease both;
}

.screen-active {
  display: block;
}

.hero-card,
.quiz-card,
.loading-card,
.result-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  padding: 14px;
}

.hero-visual {
  aspect-ratio: 5 / 3;
  border-radius: 22px;
}

.hero-copy {
  padding: 22px 10px 12px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 14vw, 4.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.lead {
  margin: 14px 0 22px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.8;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  width: 100%;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 22px;
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #ff9b6b);
  box-shadow: 0 12px 24px rgba(255, 122, 168, 0.3);
}

.secondary-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.primary-button:active,
.secondary-button:active,
.answer-button:active {
  transform: translateY(1px) scale(0.99);
}

.image-frame {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 232, 241, 0.9));
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
}

.image-frame img.is-broken {
  display: none;
}

.image-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(4rem, 28vw, 8rem);
}

.quiz-card {
  padding: 18px;
}

.progress-row {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 800;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(44, 36, 48, 0.08);
}

.progress-bar {
  width: 8.33%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 260ms ease;
}

.question-panel {
  animation: questionIn 240ms ease both;
}

.question-panel.is-changing {
  animation: questionOut 180ms ease both;
}

.question-panel h2 {
  min-height: 4.6em;
  margin: 0 0 18px;
  font-size: clamp(1.55rem, 7vw, 2.4rem);
  line-height: 1.36;
}

.answer-grid {
  display: grid;
  gap: 10px;
}

.answer-button {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  font-size: 0.98rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.answer-button:hover,
.answer-button:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 58%, #fff);
  background: rgba(255, 255, 255, 0.95);
  outline: none;
}

.loading-card {
  min-height: 360px;
  padding: 48px 24px;
  display: grid;
  place-items: center;
  text-align: center;
}

.brain-loader {
  width: 104px;
  height: 104px;
  border-radius: 34px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  background: #fff;
  font-size: 4rem;
  animation: pulse 850ms ease-in-out infinite alternate;
}

.loading-card h2 {
  margin: 0;
  font-size: 1.75rem;
}

.loading-card p {
  margin: 10px 0 0;
  color: var(--muted);
}

.result-card {
  padding: 22px;
  text-align: center;
  --theme: #ff7aa8;
  --theme-soft: #ffe5ef;
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--theme-soft) 70%, transparent), transparent 44%),
    url("assets/result-bg.webp") top center / cover no-repeat;
  opacity: 0.72;
  pointer-events: none;
}

.result-card > * {
  position: relative;
  z-index: 1;
}

.result-bg-piece {
  position: absolute;
  inset: 10px;
  border: 1px dashed color-mix(in srgb, var(--theme) 42%, transparent);
  border-radius: 22px;
  pointer-events: none;
}

.result-card .eyebrow {
  color: var(--theme);
}

.result-card h2 {
  margin: 0;
  font-size: clamp(2rem, 10vw, 3.6rem);
  line-height: 1.08;
}

.result-copy {
  margin: 10px auto 18px;
  max-width: 32rem;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.7;
}

.result-portrait {
  width: min(72vw, 290px);
  aspect-ratio: 1 / 1;
  margin: 0 auto 18px;
  border: 8px solid #fff;
  border-radius: 28px;
  box-shadow: 0 14px 32px rgba(44, 36, 48, 0.12);
}

.result-portrait img {
  object-fit: contain;
  padding: 8px;
}

.description {
  margin: 0 0 16px;
  color: var(--ink);
  line-height: 1.8;
  text-align: left;
}

.result-details {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  text-align: left;
}

.result-extra {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
  text-align: left;
}

.result-extra h3 {
  margin: 10px 0 0;
  color: var(--theme);
  font-size: 0.92rem;
  line-height: 1.5;
}

.result-extra p {
  margin: 0;
  border: 1px solid rgba(44, 36, 48, 0.1);
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.74);
  line-height: 1.8;
}

.result-details div {
  border: 1px solid rgba(44, 36, 48, 0.1);
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.74);
}

.result-details dt {
  margin-bottom: 4px;
  color: var(--theme);
  font-size: 0.78rem;
  font-weight: 900;
}

.result-details dd {
  margin: 0;
  line-height: 1.7;
}

.button-row {
  display: grid;
  gap: 10px;
}

.site-footer {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer a,
.resident-card a,
.legal-card a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.legal-card,
.residents-card {
  padding: 22px;
}

.legal-card h1,
.residents-card h1 {
  margin: 0 0 14px;
  font-size: clamp(2rem, 10vw, 3.4rem);
  line-height: 1.08;
}

.legal-card h2 {
  margin: 24px 0 8px;
  font-size: 1.12rem;
}

.legal-card p,
.legal-card li,
.residents-card p {
  color: var(--muted);
  line-height: 1.8;
}

.legal-card ul {
  padding-left: 1.2em;
}

.residents-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.resident-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(44, 36, 48, 0.1);
  border-radius: 20px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.74);
}

.resident-thumb {
  width: 92px;
  aspect-ratio: 1 / 1;
  border: 4px solid #fff;
  border-radius: 18px;
}

.resident-thumb img {
  object-fit: contain;
  padding: 4px;
}

.resident-card h2 {
  margin: 0 0 4px;
  color: var(--theme);
  font-size: 1.05rem;
}

.resident-card p {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 0.9rem;
}

@media (min-width: 720px) {
  .app-shell {
    padding: 32px 20px 44px;
  }

  .hero-card {
    padding: 18px;
  }

  .hero-copy {
    padding: 24px 12px 14px;
  }

  .quiz-card,
  .result-card {
    padding: 28px;
  }

  .button-row {
    grid-template-columns: 1fr 1fr;
  }

  .button-row:has(a:nth-child(3)) {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .legal-card,
  .residents-card {
    padding: 30px;
  }

  .residents-grid {
    grid-template-columns: 1fr 1fr;
  }
}

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

@keyframes questionIn {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes questionOut {
  to {
    opacity: 0;
    transform: translateX(-12px);
  }
}

@keyframes pulse {
  from {
    transform: rotate(-3deg) scale(0.96);
  }
  to {
    transform: rotate(3deg) scale(1.04);
  }
}

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