/* Little Complex. Mobile first: parchment, ink and wax. */
:root {
  color-scheme: light;
  --paper: #F5EDE0;
  --paper-2: #EDE1CC;
  --card: #FFFBF3;
  --ink: #1E1A2B;
  --ink-2: #463F55;
  --muted: #7A6F62;
  --line: #E0D2BB;
  --wax: #B0352B;
  --wax-2: #84251E;
  --gold: #B98A2E;
  --teal: #1F6F78;
  --plum: #6B3A6E;
  --ok: #2F7A4B;
  --a1: var(--wax);
  --a2: var(--teal);
  --a3: var(--gold);
  --radius: 18px;
  --shadow: 0 1px 0 rgba(30,26,43,.04), 0 10px 30px -12px rgba(30,26,43,.25);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100svh; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.5;
  background-image:
    radial-gradient(ellipse at 20% -10%, rgba(185,138,46,.10), transparent 55%),
    radial-gradient(ellipse at 110% 30%, rgba(176,53,43,.06), transparent 50%);
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 520px; margin: 0 auto; padding: 0 16px calc(32px + var(--safe-b)); min-height: 100svh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -.015em; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(2.3rem, 10vw, 3.2rem); font-weight: 900; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .75rem; letter-spacing: .04em; }
.caps { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 700; }
.center { text-align: center; }
.stack > * + * { margin-top: var(--gap, 16px); }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 6px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-weight: 900; font-size: 1.12rem; text-decoration: none; }
.top .link { font-size: .85rem; font-weight: 600; color: var(--ink-2); text-decoration: none; padding: 8px 4px; }

/* Wax seal */
.seal { --s: 34px; width: var(--s); height: var(--s); border-radius: 50%; display: grid; place-items: center; flex: none;
  background: radial-gradient(circle at 35% 30%, #d6574a, var(--wax) 45%, var(--wax-2) 100%);
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.25), inset 0 2px 4px rgba(255,255,255,.25), 0 2px 6px rgba(132,37,30,.35);
  color: #F8E3D8; font-family: var(--serif); font-weight: 900; font-size: calc(var(--s) * .36); letter-spacing: -.04em; }
.seal.big { --s: 120px; }
.seal.huge { --s: 150px; }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px; padding: 14px 20px;
  border-radius: 999px; font-weight: 700; font-size: 1.05rem; text-decoration: none; transition: transform .12s ease, box-shadow .2s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--ink); color: var(--paper); box-shadow: 0 10px 24px -10px rgba(30,26,43,.6); }
.btn-wax { background: var(--wax); color: #fff; box-shadow: 0 10px 24px -10px rgba(176,53,43,.7); }
.btn-ghost { background: transparent; border: 1.5px solid var(--ink); }
.btn-soft { background: var(--card); border: 1px solid var(--line); }
.btn-sm { min-height: 44px; font-size: .95rem; padding: 10px 16px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.letter { position: relative; background: var(--card); border-radius: 6px; padding: 26px 22px 22px; box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(transparent, transparent 31px, rgba(30,26,43,.035) 32px); border: 1px solid var(--line); }
.letter::before { content: ''; position: absolute; inset: 6px; border: 1px solid rgba(185,138,46,.25); border-radius: 3px; pointer-events: none; }

/* Portraits */
.pt { --s: 56px; width: var(--s); height: var(--s); border-radius: 50%; overflow: hidden; flex: none; background: var(--paper-2); position: relative;
  box-shadow: 0 0 0 3px var(--card), 0 0 0 4px var(--line); }
.pt img { width: 100%; height: 100%; object-fit: cover; filter: sepia(.25) contrast(1.05); }
.pt .mono { width: 100%; height: 100%; display: grid; place-items: center; font-family: var(--serif); font-weight: 900; color: #fff; font-size: calc(var(--s) * .38); }
.pt.lg { --s: 92px; } .pt.xl { --s: 120px; } .pt.sm { --s: 36px; } .pt.xs { --s: 26px; box-shadow: 0 0 0 2px var(--card); }

/* Landing */
.hero { padding: 18px 0 8px; }
.hero h1 .line2 { display: block; color: var(--wax); font-style: italic; font-weight: 700; }
.trio { display: flex; justify-content: center; margin: 26px 0 14px; }
.trio .pt { --s: 88px; margin: 0 -10px; transition: transform .5s cubic-bezier(.2,.8,.2,1), opacity .4s; }
.trio .pt:nth-child(2) { --s: 104px; z-index: 2; transform: translateY(-8px); }
.rotator { min-height: 3.4em; font-family: var(--serif); font-size: 1.25rem; text-align: center; line-height: 1.35; transition: opacity .35s; }
.rotator b { color: var(--wax); font-weight: 700; }
.facts { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; font-weight: 500; margin-top: 12px; }
.facts span::before { content: '✦ '; color: var(--gold); }
.proof { text-align: center; font-size: .9rem; color: var(--ink-2); margin-top: 14px; }
.howto { display: grid; gap: 10px; margin-top: 28px; }
.howto .step { display: flex; gap: 12px; align-items: flex-start; }
.howto .num { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }

/* Progress */
.progress { display: flex; gap: 4px; margin: 4px 0 18px; }
.progress .seg { flex: var(--n); height: 6px; background: var(--paper-2); border-radius: 99px; overflow: hidden; }
.progress .seg i { display: block; height: 100%; width: 0; background: var(--ink); border-radius: 99px; transition: width .35s ease; }
.qmeta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .8rem; font-weight: 600; margin-bottom: 10px; }
.back { padding: 8px 0; font-weight: 600; color: var(--ink-2); }

/* Question */
.q-enter { animation: qin .38s cubic-bezier(.2,.8,.2,1) both; }
@keyframes qin { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
.q-text { font-family: var(--serif); font-size: 1.45rem; line-height: 1.25; font-weight: 700; }
.opts { display: grid; gap: 10px; margin-top: 18px; }
.opt { text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 15px 16px; font-size: 1rem; font-weight: 500;
  min-height: 56px; transition: transform .1s, border-color .15s, background .15s; display: flex; gap: 12px; align-items: center; }
.opt .k { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: var(--muted); flex: none; }
.opt:active { transform: scale(.98); }
.opt.picked { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.opt.picked .k { border-color: var(--paper); color: var(--paper); }
.opts.locked .opt:not(.picked) { opacity: .45; }

/* Lightning */
.bin { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.bin .opt { min-height: 132px; justify-content: center; text-align: center; font-family: var(--serif); font-size: 1.25rem; font-weight: 700; padding: 16px 10px; }
.timer { height: 4px; background: var(--paper-2); border-radius: 9px; overflow: hidden; margin-top: 18px; }
.timer i { display: block; height: 100%; background: var(--wax); width: 100%; transform-origin: left; }
.timer.run i { animation: drain var(--t, 6s) linear forwards; }
@keyframes drain { to { transform: scaleX(0); } }
.lightning-q { font-family: var(--serif); font-size: 2rem; font-weight: 900; text-align: center; margin-top: 30px; line-height: 1.1; }

/* Twin toast */
.twin { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translate(-50%, 140%); background: var(--ink); color: var(--paper);
  border-radius: 999px; padding: 8px 16px 8px 8px; display: flex; align-items: center; gap: 10px; font-size: .9rem; box-shadow: 0 12px 30px -10px rgba(0,0,0,.5);
  transition: transform .35s cubic-bezier(.2,.9,.3,1.2); z-index: 40; max-width: calc(100% - 32px); }
.twin.show { transform: translate(-50%, 0); }
.twin .pt { --s: 34px; box-shadow: none; }
.twin b { font-weight: 700; }
.twin span { white-space: nowrap; }

/* Round interstitial */
.round { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 30px 0; animation: qin .45s both; }
.round .caps { color: var(--wax); }
.round h2 { font-size: 2.6rem; font-weight: 900; margin: 8px 0 12px; }

/* Sign */
.sig-input { width: 100%; font-family: var(--serif); font-size: 1.6rem; font-style: italic; border: 0; border-bottom: 2px solid var(--ink); background: transparent; padding: 8px 2px; outline: none; color: var(--ink); }
.sig-input::placeholder { color: #b9ad9c; }

/* Envelope reveal */
.env-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 20px 0; }
.envelope { position: relative; width: 100%; max-width: 340px; aspect-ratio: 1.45; background: #EADBC2; border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.envelope::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom right, transparent 49.5%, rgba(0,0,0,.06) 50%), linear-gradient(to bottom left, transparent 49.5%, rgba(0,0,0,.06) 50%); }
.envelope .flap { position: absolute; left: 0; right: 0; top: 0; height: 58%; background: #E2D0B2; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform .6s ease; }
.envelope .seal { position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%); --s: 84px; font-size: 1.9rem; transition: transform .25s; }
.envelope.tap .seal { animation: wobble 1.6s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { transform: translate(-50%, -50%) rotate(0); } 50% { transform: translate(-50%, -50%) rotate(-6deg) scale(1.04); } }
.envelope.open .seal { animation: crack .5s forwards; }
@keyframes crack { 40% { transform: translate(-50%, -50%) scale(1.15); } 100% { transform: translate(-50%, -50%) scale(.2) rotate(40deg); opacity: 0; } }
.envelope.open .flap { transform: rotateX(180deg); }

/* Result */
.res-head { padding: 10px 0 4px; }
.res-head h1 { font-size: clamp(1.9rem, 8.4vw, 2.5rem); line-height: 1.12; }
.res-head h1 em { font-style: normal; color: var(--wax); }
.deal { opacity: 0; transform: translateY(24px) rotate(-1.5deg); animation: deal .55s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes deal { to { opacity: 1; transform: none; } }
.fig { display: flex; gap: 14px; align-items: flex-start; }
.fig .pct { font-family: var(--serif); font-weight: 900; font-size: 1.7rem; line-height: 1; color: var(--acc, var(--wax)); }
.fig .name { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; line-height: 1.15; }
.fig .title { color: var(--muted); font-size: .82rem; font-weight: 600; margin-top: 2px; }
.fig .line { margin-top: 10px; font-size: 1rem; }
.fig .line .lbl { font-weight: 700; color: var(--acc, var(--wax)); }
.fig .bar { height: 5px; border-radius: 9px; background: var(--paper-2); margin-top: 10px; overflow: hidden; }
.fig .bar i { display: block; height: 100%; background: var(--acc, var(--wax)); width: 0; transition: width 1s cubic-bezier(.2,.8,.2,1); }
.split { font-size: .85rem; color: var(--ink-2); margin-top: 8px; }
.split b { font-weight: 700; }
.complex { background: var(--ink); color: var(--paper); border-radius: var(--radius); padding: 22px 20px; position: relative; overflow: hidden; }
.complex .caps { color: #E7B9A8; }
.complex .q { font-family: var(--serif); font-size: 1.35rem; line-height: 1.3; margin-top: 8px; }
.complex .cx { margin-top: 12px; color: #D9CFE0; font-size: .95rem; }
.complex .cx b { color: #fff; }
.react { display: flex; gap: 8px; margin-top: 14px; }
.react button { flex: 1; min-height: 46px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--line); font-weight: 700; font-size: .92rem; }
.react button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.share-grid button, .share-grid a { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; padding: 10px 2px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); text-decoration: none; }
.share-grid .ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: .95rem; font-weight: 700; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 30px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .78rem; font-weight: 600; padding: 5px 10px; border-radius: 99px; background: var(--paper-2); color: var(--ink-2); }
.chip.hi { background: rgba(176,53,43,.12); color: var(--wax-2); }

/* Compare */
.vs { display: flex; align-items: center; justify-content: center; gap: 14px; }
.vs .score { font-family: var(--serif); font-weight: 900; font-size: 3rem; line-height: 1; }
.meter { position: relative; height: 10px; background: var(--paper-2); border-radius: 9px; margin: 8px 0 2px; }
.meter .you, .meter .them { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid var(--card); }
.meter .you { background: var(--wax); } .meter .them { background: var(--teal); }
.meter-l { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); font-weight: 600; }

/* Lineup (guess) */
.lineup { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lineup button { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: .8rem; font-weight: 600; line-height: 1.2; text-align: center; transition: transform .1s; }
.lineup button .pt { --s: 64px; }
.lineup button.on { border-color: var(--wax); background: #FBEAE5; }
.lineup button.right { border-color: var(--ok); background: #E7F3EA; }
.lineup button.wrong { opacity: .5; }

/* Group */
.member { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.member .who { font-weight: 700; }
.member .sup { font-size: .82rem; color: var(--wax-2); font-weight: 600; }
.member .mix { font-size: .82rem; color: var(--muted); }
.faces { display: flex; }
.faces .pt { margin-left: -8px; } .faces .pt:first-child { margin-left: 0; }

/* Pantheon grid */
.pgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pcell { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .68rem; font-weight: 600; text-align: center; line-height: 1.15; }
.pcell .pt { --s: 64px; }
.pcell.locked .pt img, .pcell.locked .pt .mono { filter: grayscale(1) brightness(.35) blur(2px); }
.pcell.locked { color: var(--muted); }
.count-big { font-family: var(--serif); font-weight: 900; font-size: 2.2rem; }
.meter-bar { height: 8px; border-radius: 9px; background: var(--paper-2); overflow: hidden; } .meter-bar i { display: block; height: 100%; background: var(--wax); }

/* Sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(30,26,43,.45); z-index: 50; opacity: 0; transition: opacity .25s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--paper); border-radius: 22px 22px 0 0; max-height: 88svh; overflow: auto;
  padding: 10px 18px calc(24px + var(--safe-b)); transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.8,.2,1); max-width: 560px; margin: 0 auto; }
.sheet.show { transform: none; } .sheet-bg.show { opacity: 1; }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 14px; }

/* Dossier */
.lockwrap { position: relative; min-height: 190px; }
.lockwrap .blur { filter: blur(6px); pointer-events: none; user-select: none; }
.lockwrap .lock { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-start; padding-top: 28px !important; align-items: center; gap: 10px; text-align: center; padding: 18px;
  background: linear-gradient(to bottom, rgba(255,251,243,.55), rgba(255,251,243,.92) 60%); }
.tmap .trow { display: grid; grid-template-columns: 1fr 120px 1fr; gap: 8px; align-items: center; font-size: .78rem; padding: 4px 0; }
.tmap .trow .l { text-align: right; color: var(--muted); } .tmap .trow .r { color: var(--muted); }
.tmap .trow .l.on, .tmap .trow .r.on { color: var(--ink); font-weight: 700; }
.tmap .track { position: relative; height: 8px; background: var(--paper-2); border-radius: 9px; }
.tmap .track::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line); }
.tmap .track i { position: absolute; top: 0; bottom: 0; border-radius: 9px; background: var(--wax); }
.tmap .clh { font-family: var(--serif); font-weight: 700; margin: 14px 0 4px; }
.rank { display: grid; grid-template-columns: 26px 30px 1fr 54px; gap: 8px; align-items: center; padding: 6px 0; font-size: .88rem; border-bottom: 1px dashed var(--line); }
.rank .n { color: var(--muted); font-weight: 600; font-size: .78rem; }
.price { font-family: var(--serif); font-weight: 900; font-size: 2.4rem; }
.price s { font-size: 1.1rem; color: var(--muted); font-weight: 600; }
.demo-tag { display: inline-block; background: var(--gold); color: #fff; font-size: .7rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; letter-spacing: .06em; }

/* Toast */
#toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -160%); background: var(--ink); color: var(--paper); padding: 10px 16px;
  border-radius: 999px; font-size: .9rem; font-weight: 600; z-index: 60; transition: transform .3s; max-width: calc(100% - 32px); text-align: center; }
#toast.show { transform: translate(-50%, 0); }

.foot { margin-top: 40px; text-align: center; color: var(--muted); font-size: .75rem; }
.foot a { color: var(--muted); }
.fade-in { animation: qin .4s both; }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: sp 1s linear infinite; margin: 40px auto; }
@keyframes sp { to { transform: rotate(360deg); } }
input.field { width: 100%; font: inherit; padding: 14px 16px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); outline: none; }
input.field:focus { border-color: var(--ink); }
@media (min-width: 560px) { .pgrid { grid-template-columns: repeat(5, 1fr); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
