:root {
  --bg: #FBF6EE;
  --surface: #FFFFFF;
  --ink: #1F2430;
  --muted: #6A6F7C;
  --line: #E9E1D3;
  --a: #F26B5B;
  --a-soft: #FDE4E0;
  --b: #2BA6A0;
  --b-soft: #D9F1EF;
  --warn: #B3261E;
  --radius: 22px;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181F;
    --surface: #1F222B;
    --ink: #F4EFE6;
    --muted: #A2A7B3;
    --line: #2F3340;
    --a: #FF8272;
    --a-soft: #3A2522;
    --b: #4CC4BD;
    --b-soft: #1D3433;
    --warn: #FF8A80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--bg);
  padding: 10px 14px; border-radius: 10px; z-index: 10;
}
.skip:focus { top: 8px; }

a { color: inherit; }
:focus-visible { outline: 3px solid var(--b); outline-offset: 3px; border-radius: 8px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top));
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.brand svg circle:last-child { mix-blend-mode: multiply; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  background: var(--b-soft); color: var(--ink); padding: 6px 10px; border-radius: 999px;
}

main { max-width: 760px; margin: 0 auto; padding: 0 16px 24px; }

.hero { padding: 18px 0 8px; text-align: center; }
.hero h1 {
  font-family: var(--serif); font-weight: 700; font-size: clamp(32px, 8.4vw, 52px);
  line-height: 1.08; letter-spacing: -.02em; margin: 0 0 12px;
}
.hero h1 em { font-style: italic; color: var(--a); }
.lede { color: var(--muted); font-size: 17px; margin: 0 auto; max-width: 560px; }

.app, .result {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 14px 20px; margin-top: 18px; box-shadow: 0 10px 30px -18px rgba(31, 36, 48, .35);
}

.names { display: flex; justify-content: center; margin-bottom: 14px; }
.field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; width: min(100%, 260px); text-align: center; }
.field i { font-weight: 500; color: var(--muted); font-style: normal; }
.field input, .label-input {
  font: inherit; color: inherit; background: var(--bg); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 12px; text-align: center; width: 100%;
}
.field input:focus, .label-input:focus { border-color: var(--b); outline: none; }

.tiles { display: grid; grid-template-columns: 1fr 1.18fr 1fr; gap: 10px; align-items: start; }
.tile { display: grid; gap: 8px; text-align: center; position: relative; }
.tile .file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tile .file:focus-visible + .drop { outline: 3px solid var(--b); outline-offset: 3px; }

.drop {
  position: relative; display: grid; place-items: center; aspect-ratio: 1; width: 100%;
  border-radius: 50%; cursor: pointer; background: var(--a-soft); color: var(--a);
  border: 2.5px dashed currentColor; overflow: hidden; transition: transform .15s ease, background .2s;
  -webkit-tap-highlight-color: transparent;
}
#tile-b .drop { background: var(--b-soft); color: var(--b); }
#tile-c .drop { background: var(--line); color: var(--muted); }
.drop:active { transform: scale(.97); }
.drop.dragover { transform: scale(1.04); }
.ph { display: grid; place-items: center; }
.thumb { position: absolute; inset: 0; width: 100%; height: 100%; display: none; object-fit: cover; }
.tile.has-photo .thumb { display: block; }
.tile.has-photo .ph { display: none; }
.tile.has-photo .drop { border-style: solid; border-width: 4px; }
.tile.ok .drop { color: #2E9E5B; }
.tile.bad .drop { color: var(--warn); }

.badge {
  position: absolute; right: 6%; bottom: 6%; width: 26px; height: 26px; border-radius: 50%;
  display: none; place-items: center; font-size: 15px; font-weight: 800; color: #fff; background: #2E9E5B;
  box-shadow: 0 0 0 3px var(--surface);
}
.tile.ok .badge { display: grid; }
.tile.ok .badge::before { content: "\2713"; }
.tile.bad .badge { display: grid; background: var(--warn); }
.tile.bad .badge::before { content: "!"; }
.tile.busy .drop { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .6; } }

.label-input { font-weight: 700; padding: 8px 6px; font-size: 15px; }
.role-label { margin: 0; font-weight: 700; padding: 9px 0; font-size: 15px; }
.status { margin: 0; font-size: 12px; color: var(--muted); min-height: 2.6em; line-height: 1.3; }
.tile.bad .status { color: var(--warn); }

.tip { font-size: 13px; color: var(--muted); text-align: center; margin: 14px 0 6px; }

.engine { margin: 12px auto 0; max-width: 420px; text-align: center; font-size: 13px; color: var(--muted); }
.engine .bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.engine .bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--a), var(--b)); transition: width .25s ease; }
.engine p { margin: 6px 0 0; }

.error { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 12px 0 0; text-align: center; }

.cta, .ghost {
  font: inherit; font-weight: 700; border-radius: 16px; border: 0; cursor: pointer;
  padding: 15px 22px; min-height: 52px; transition: transform .12s ease, opacity .2s, filter .2s;
  -webkit-tap-highlight-color: transparent;
}
.cta { background: var(--ink); color: var(--bg); width: 100%; margin-top: 14px; font-size: 17px; }
.cta:hover:not(:disabled) { filter: brightness(1.12); }
.cta:active:not(:disabled), .ghost:active { transform: scale(.98); }
.cta:disabled { opacity: .35; cursor: not-allowed; }
.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.ghost:hover { border-color: var(--ink); }

.fine { font-size: 12px; color: var(--muted); text-align: center; margin: 10px 0 0; }

/* Result */
.result { text-align: center; animation: rise .5s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.kicker { margin: 4px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.result h2 { font-family: var(--serif); font-size: clamp(30px, 8vw, 44px); line-height: 1.1; letter-spacing: -.02em; margin: 6px 0 6px; }
.sub { color: var(--muted); margin: 0 auto 18px; max-width: 460px; }

.meter { display: flex; height: 22px; border-radius: 99px; overflow: hidden; background: var(--line); }
.meter-fill { width: 50%; transition: width 1.1s cubic-bezier(.2, .8, .2, 1); }
.meter-fill.a { background: var(--a); }
.meter-fill.b { background: var(--b); }
.pcts { display: flex; justify-content: space-between; margin-top: 10px; text-align: left; }
.pcts .right { text-align: right; }
.pcts strong { display: block; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.pcts span { font-size: 14px; color: var(--muted); font-weight: 600; }
.pcts > div:first-child strong { color: var(--a); }
.pcts > div:last-child strong { color: var(--b); }

.result h3 { margin: 26px 0 10px; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; text-align: left; }
.feat { display: grid; grid-template-columns: 84px 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.feat .name { font-weight: 700; }
.feat .track { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--line); }
.feat .track i { display: block; height: 100%; transition: width 1s cubic-bezier(.2, .8, .2, 1); width: 50%; }
.feat .track i:first-child { background: var(--a); }
.feat .track i:last-child { background: var(--b); }
.feat .who { font-weight: 700; font-size: 13px; min-width: 64px; text-align: right; }
.feat .who.a { color: var(--a); }
.feat .who.b { color: var(--b); }
.feat .who.tie { color: var(--muted); }

.card-wrap { margin: 26px auto 0; max-width: 360px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 14px 34px -18px rgba(31, 36, 48, .5); }
.card-wrap canvas { display: block; width: 100%; height: auto; }

.actions { display: grid; gap: 10px; margin-top: 18px; }
.actions .cta { margin-top: 0; }

/* Info */
.info { margin-top: 34px; }
.info h2 { font-family: var(--serif); font-size: 26px; letter-spacing: -.01em; margin: 28px 0 10px; }
.steps { padding-left: 20px; display: grid; gap: 10px; color: var(--muted); }
.steps strong { color: var(--ink); }
details { border-bottom: 1px solid var(--line); padding: 14px 2px; }
summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-size: 22px; line-height: 1; color: var(--muted); }
details[open] summary::after { content: "\2212"; }
details p { color: var(--muted); margin: 8px 0 0; }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 40px; }
.foot p { margin: 4px 0; }

/* Legal pages */
.doc { max-width: 680px; margin: 0 auto; padding: 8px 16px 48px; }
.doc h1 { font-family: var(--serif); font-size: 36px; letter-spacing: -.02em; }
.doc h2 { font-size: 19px; margin-top: 28px; }
.doc p, .doc li { color: var(--muted); }
.doc strong { color: var(--ink); }

@media (min-width: 560px) {
  .app, .result { padding: 26px 26px 28px; }
  .tiles { gap: 18px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .cta { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Guess first mode */
.toggle { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 16px 0 0; font-weight: 600; font-size: 15px; cursor: pointer; }
.toggle i { font-style: normal; font-weight: 500; color: var(--muted); }
.toggle input { width: 22px; height: 22px; accent-color: var(--b); flex: none; }
.guess { text-align: center; animation: rise .4s ease both; }
.guess h2 { font-family: var(--serif); font-size: 28px; margin: 4px 0 4px; letter-spacing: -.01em; }
.guess .sub { margin-bottom: 14px; }
.gplayer { margin: 14px 0; }
.gname { font-weight: 700; margin: 0 0 8px; font-size: 15px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg-btn {
  font: inherit; font-weight: 700; padding: 14px 10px; min-height: 52px; border-radius: 14px; cursor: pointer;
  background: var(--bg); color: var(--ink); border: 2px solid var(--line); transition: transform .12s ease, border-color .15s, background .15s;
}
.seg-btn:active { transform: scale(.97); }
.seg-btn.a.on { background: var(--a); border-color: var(--a); color: #fff; }
.seg-btn.b.on { background: var(--b); border-color: var(--b); color: #fff; }

.score { font-weight: 800; font-size: 17px; margin: -6px auto 16px; padding: 8px 14px; border-radius: 99px; background: var(--b-soft); display: inline-block; }

/* Tip jar */
.tipjar { margin-top: 26px; padding-top: 20px; border-top: 1px dashed var(--line); }
.tipjar p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.tip-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tip-btn {
  display: block; text-decoration: none; text-align: center; font-weight: 700; font-size: 14px; color: var(--ink);
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 6px; transition: border-color .15s, transform .12s;
}
.tip-btn { position: relative; overflow: visible; }
.tip-ic { display: block; font-size: 30px; line-height: 1.1; margin-bottom: 4px; animation: tipwiggle 3.2s ease-in-out infinite; animation-delay: calc(var(--i, 0) * .4s); transform-origin: 50% 80%; }
.tip-btn:hover { border-color: var(--ink); }
.tip-btn:hover .tip-ic { animation: tipbounce .5s ease; }
.tip-pop { position: absolute; left: 50%; top: 30%; font-size: 18px; pointer-events: none; opacity: 0; animation: tippop 1s ease-out var(--d, 0ms) forwards; }
@keyframes tipwiggle { 0%, 82%, 100% { transform: rotate(0); } 86% { transform: rotate(-12deg); } 90% { transform: rotate(10deg); } 94% { transform: rotate(-6deg); } }
@keyframes tipbounce { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-8px) scale(1.2); } }
@keyframes tippop { 0% { opacity: 1; transform: translate(-50%, 0) scale(.6); } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), var(--dy)) scale(1.2); } }
@media (prefers-reduced-motion: reduce) { .tip-ic, .tip-btn:hover .tip-ic { animation: none; } }
.tip-btn:active { transform: scale(.97); }

.presets{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin:0 0 14px}
.presets button{font:inherit;font-size:.9rem;padding:8px 14px;border-radius:999px;border:1.5px solid var(--line,#e6dccb);background:transparent;color:inherit;cursor:pointer}
.presets button.on{background:var(--a,#e8604c);border-color:var(--a,#e8604c);color:#fff}
