:root {
  --ink: #24221f;
  --muted: #736b61;
  --paper: #f6f0e8;
  --cream: #fffaf3;
  --line: rgba(36, 34, 31, 0.12);
  --coral: #de725f;
  --coral-dark: #b9503f;
  --sage: #6f8a6f;
  --night: #2a211d;
  --radius: 24px;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 8% 4%, rgba(222,114,95,.14), transparent 28rem),
    radial-gradient(circle at 96% 92%, rgba(111,138,111,.15), transparent 26rem),
    var(--paper);
}
button { font: inherit; color: inherit; }
h1, h2 { font-family: "Newsreader", Georgia, serif; font-weight: 600; letter-spacing: -.02em; margin: 0; }

.shell {
  width: min(100%, 460px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.loading { align-items: center; justify-content: center; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { width: 26px; height: 26px; border-radius: 50% 50% 42% 58%; background: var(--coral); transform: rotate(-12deg); display: grid; place-items: center; color: #fff; font-family: Georgia, serif; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .74rem; font-weight: 700; color: var(--coral-dark); margin: 0 0 8px; }

/* Buttons */
.btn { border: 0; border-radius: 999px; padding: 15px 22px; font-weight: 700; font-size: 1.02rem; cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: transform .12s ease, background .2s ease; }
.btn:active { transform: scale(.98); }
.btn small { font-weight: 500; font-size: .78rem; opacity: .8; }
.btn-primary { background: var(--coral); color: #fff; box-shadow: 0 10px 26px rgba(222,114,95,.35); }
.btn-primary:hover { background: var(--coral-dark); }
.btn-light { background: var(--cream); border: 1px solid var(--line); }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn:disabled { opacity: .55; cursor: default; }
.text-link { background: none; border: 0; padding: 6px 4px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: .9rem; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--cream); display: grid; place-items: center; cursor: pointer; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 11px; background: rgba(255,250,243,.14); font-weight: 700; font-size: .82rem; border: 0; }
.chip-strong { background: var(--night); color: var(--cream); cursor: pointer; padding: 8px 14px; }
.chip-strong small { opacity: .7; font-weight: 500; }
.notice { background: #fff1ec; border: 1px solid #f1c2b6; border-radius: 14px; padding: 12px 14px; color: #8a3727; }

/* Landing */
.home .hero { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 4px; }
.home h1 { font-size: clamp(3rem, 14vw, 4.4rem); line-height: .95; margin-bottom: 18px; }
.hero-copy { font-size: 1.1rem; line-height: 1.5; color: var(--muted); margin: 0 0 28px; }
.hero-actions { display: grid; gap: 10px; }
.privacy { display: flex; gap: 8px; align-items: flex-start; font-size: .86rem; color: var(--muted); margin-top: 22px; line-height: 1.45; }
.privacy svg { flex: none; margin-top: 2px; }
.pilot-link { align-self: center; font-size: .82rem; }

/* Rate */
.rate { height: 100dvh; min-height: 0; overflow: hidden; gap: 10px; }
.rate-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rate-tools { display: flex; align-items: center; gap: 10px; }
.progress { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .85rem; color: var(--muted); }
.progress-bar { width: 96px; height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--coral); border-radius: inherit; transition: width .25s ease; }
.stage { flex: 1; min-height: 0; display: grid; place-items: center; }
.deck { position: relative; width: min(100%, calc((100dvh - 262px) * .8), 512px); aspect-ratio: 4 / 5; }
.card {
  position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden; background: #ddd5ca;
  box-shadow: 0 18px 44px rgba(67,53,39,.2); touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
  transition: transform .23s cubic-bezier(.2,.8,.2,1), opacity .23s ease;
  will-change: transform;
}
.card img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; pointer-events: none; -webkit-user-drag: none; }
.card[data-role="back"] { transform: scale(.94) translateY(12px); opacity: .9; box-shadow: none; cursor: default; }
.card[data-role="top"] { z-index: 2; }
.card.dragging { transition: none; cursor: grabbing; }
.card.leaving { pointer-events: none; }
.card.undo-from-left { transform: translate(-120%, 0) rotate(-18deg); transition: none; }
.card.undo-from-right { transform: translate(120%, 0) rotate(18deg); transition: none; }
.card.undo-from-top { transform: translateY(-110%); transition: none; }
.stamp { position: absolute; top: 26px; padding: 6px 14px; border: 4px solid; border-radius: 10px; font-weight: 800; font-size: 1.8rem; letter-spacing: .06em; opacity: 0; transition: opacity .1s; background: rgba(255,255,255,.12); }
.stamp-yes { left: 22px; color: #2f9e62; border-color: #2f9e62; transform: rotate(-14deg); }
.stamp-no { right: 22px; color: #e0503d; border-color: #e0503d; transform: rotate(14deg); }
.prompt { text-align: center; margin: 0; font-family: "Newsreader", Georgia, serif; font-size: 1.25rem; font-weight: 600; }
.answer-bar { display: flex; justify-content: center; gap: 34px; }
.round-btn { width: 72px; height: 72px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--cream); box-shadow: 0 10px 24px rgba(67,53,39,.16); transition: transform .12s ease; }
.round-btn:active { transform: scale(.92); }
.round-btn.no { color: #e0503d; }
.round-btn.yes { color: #fff; background: var(--coral); }
.secondary-actions { display: flex; justify-content: center; align-items: center; gap: 6px; color: var(--muted); flex-wrap: wrap; }
.swipe-hint { text-align: center; color: var(--muted); font-size: .85rem; margin: 0; }
.pair-title { text-align: center; font-family: "Newsreader", Georgia, serif; font-size: 1.45rem; font-weight: 600; margin: 6px 0 0; }
.pair-cue { text-align: center; color: var(--muted); margin: -4px 0 0; font-size: .9rem; }
.pair-stage { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; }
.pair-card { padding: 0; border: 3px solid transparent; border-radius: 20px; overflow: hidden; background: #ddd5ca; cursor: pointer; height: min(100%, 600px); width: 100%; transition: transform .2s ease, opacity .2s ease, border-color .2s ease; box-shadow: 0 12px 30px rgba(67,53,39,.16); }
.pair-card img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; -webkit-user-drag: none; }
.pair-card:hover { border-color: rgba(222,114,95,.5); }
.pair-card.chosen { border-color: var(--coral); transform: scale(1.03); }
.pair-card.passed { opacity: .35; transform: scale(.96); }

/* Results */
.results { gap: 16px; padding-bottom: 40px; }
.results-head { display: flex; justify-content: space-between; align-items: center; }
.type-card { background: linear-gradient(155deg, var(--night), #5b2f27); color: var(--cream); border-radius: 28px; padding: 26px 22px 22px; box-shadow: 0 24px 60px rgba(42,33,29,.3); }
.type-card .eyebrow { color: #f2a48f; }
.type-card h1 { font-size: clamp(2.2rem, 10vw, 2.9rem); line-height: 1; margin-bottom: 12px; }
.breadth { margin: 0 0 16px; color: rgba(255,250,243,.75); font-size: .95rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.traits { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.trait { background: rgba(255,250,243,.08); border-radius: 16px; padding: 12px 14px; }
.trait-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.trait-top strong { font-size: 1.08rem; }
.grade { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.grade-strong { color: #f2a48f; opacity: 1; }
.meter { height: 6px; border-radius: 99px; background: rgba(255,250,243,.15); margin: 8px 0 6px; overflow: hidden; }
.meter span { display: block; height: 100%; background: #f2a48f; border-radius: inherit; }
.trait-hint .meter span { background: rgba(255,250,243,.45); }
.trait small { color: rgba(255,250,243,.7); }
.mystery { color: rgba(255,250,243,.8); line-height: 1.5; margin: 0; }
.accuracy { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid rgba(255,250,243,.14); color: rgba(255,250,243,.85); }
.accuracy strong { color: #f2a48f; }
.result-actions { display: grid; gap: 10px; }
.panel { background: var(--cream); border: 1px solid var(--line); border-radius: 22px; padding: 18px; }
.panel h2 { font-size: 1.5rem; margin-bottom: 4px; }
.panel-note { color: var(--muted); margin: 0 0 12px; font-size: .92rem; }
.match-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.match { margin: 0; position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 5; background: #ddd5ca; }
.match img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; }
.match figcaption { position: absolute; left: 6px; bottom: 6px; background: rgba(36,34,31,.72); color: #fff; border-radius: 99px; padding: 2px 8px; font-size: .74rem; font-weight: 700; }
.generated { width: 100%; border-radius: 16px; margin-top: 12px; }
.how summary { cursor: pointer; font-weight: 700; }
.how p { color: var(--muted); line-height: 1.5; }
.evidence-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.evidence-table th, .evidence-table td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.fineprint { font-size: .8rem; }
.reveal .type-card { animation: reveal .7s cubic-bezier(.2,.8,.2,1) both; }
.reveal .type-card .trait { animation: rise .5s ease both; }
.reveal .type-card .trait:nth-child(2) { animation-delay: .12s; }
.reveal .type-card .trait:nth-child(3) { animation-delay: .24s; }
.reveal .type-card .trait:nth-child(4) { animation-delay: .36s; }
@keyframes reveal { from { transform: scale(.9) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Guess */
.guess { gap: 12px; }
.guess h1 { font-size: 2.3rem; line-height: 1.05; }
.guess-form { display: grid; gap: 12px; }
.guess-form fieldset { border: 1px solid var(--line); border-radius: 18px; padding: 12px; margin: 0; background: var(--cream); }
.guess-form legend { font-weight: 700; padding: 0 6px; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: block; text-align: center; padding: 10px 4px; border-radius: 12px; border: 1px solid var(--line); font-size: .85rem; font-weight: 600; cursor: pointer; }
.choice input:checked + span { background: var(--night); color: var(--cream); border-color: var(--night); }
.choice input:focus-visible + span { outline: 3px solid var(--coral); }
.guess-results { list-style: none; padding: 0; margin: 8px 0 16px; display: grid; gap: 8px; }
.guess-results li { display: grid; gap: 2px; background: var(--cream); border-radius: 14px; padding: 12px 14px; border-left: 5px solid var(--line); }
.guess-results li.hit { border-left-color: #2f9e62; }
.guess-results li.miss { border-left-color: #e0503d; }
.guess-results span, .guess-results small { color: var(--muted); font-size: .82rem; }
.guess-results em { font-style: normal; font-size: .72rem; text-transform: uppercase; color: var(--coral-dark); }

/* Misc */
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--coral); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
.spinner.small { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--night); color: var(--cream); padding: 10px 16px; border-radius: 99px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; font-weight: 600; z-index: 10; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }

@media (min-width: 760px) {
  .shell { width: min(100%, 520px); }
}
@media (max-height: 700px) {
  .round-btn { width: 60px; height: 60px; }
  .prompt { display: none; }
  .deck { width: min(100%, calc((100dvh - 200px) * .8)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
