:root {
  --bg: #fff4e2;
  --ink: #141414;
  --orange: #ff5a1f;
  --yellow: #ffe14a;
  --green: #16b862;
  --red: #ff4646;
  --muted: #847b6c;
  --ui: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg) radial-gradient(#14141414 1.2px, transparent 1.4px) 0 0 / 22px 22px;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }

.app {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 14px max(8px, env(safe-area-inset-bottom));
}

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 40px; flex: none; }
.logo { display: flex; align-items: center; gap: 3px; font: 700 23px var(--ui); letter-spacing: -1.2px; color: var(--ink); text-decoration: none; }
.logo span { color: var(--orange); font-size: 27px; margin-right: 3px; }
.logo b { color: var(--orange); }
.top-right { display: flex; align-items: center; gap: 8px; }
.pill {
  position: relative; display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 11px;
  background: #fff; border: 2px solid var(--ink); border-radius: 99px; box-shadow: 2px 2px 0 var(--ink);
  font: 700 14px var(--ui);
}
.pill-btn { transition: background .15s, transform .1s, box-shadow .1s; }
.pill-btn:active { transform: translate(1px, 1px); box-shadow: none; }
.pill-dna { background: var(--yellow); }
.pill-dna.pulse { animation: pop .45s cubic-bezier(.3, 1.8, .5, 1); }
.score b { min-width: 1ch; }
.score.bump { animation: bump .45s cubic-bezier(.3, 1.8, .5, 1); }

/* Name bar — the main input */
.names-wrap { position: relative; flex: none; margin-top: 10px; z-index: 40; }
.names {
  display: flex; align-items: center; gap: 6px; min-height: 56px; padding: 6px 7px 6px 12px;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 18px; box-shadow: 3px 3px 0 var(--ink);
}
.names.shake { animation: shake .45s; }
.names-icon { font-size: 22px; flex: none; }
.name-input {
  flex: 1 1 0; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; padding: 6px 2px;
  font: 700 21px var(--ui); letter-spacing: -.4px;
}
.name-input::placeholder { color: #b9b0a0; font-weight: 500; }
.name-input.pulse:placeholder-shown { animation: glow 1.6s ease-in-out infinite; border-radius: 8px; }
.amp { font: 700 19px var(--ui); color: var(--orange); flex: none; }
.add-friend, .remove-friend {
  flex: none; height: 40px; border: 2px solid var(--ink); border-radius: 12px; background: var(--yellow);
  font: 700 14px var(--ui); padding: 0 11px; white-space: nowrap;
}
.remove-friend { background: #fff; width: 34px; padding: 0; font-size: 20px; line-height: 1; }
.add-friend:active, .remove-friend:active { transform: translateY(1px); }
/* Before a name exists, this one line sits where the vibe chips go: the only thing the screen asks for. */
.coach {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 44px; margin-top: 6px;
  font: 600 15px var(--ui); letter-spacing: -.2px; text-align: center;
}
.coach b { background: var(--yellow); padding: 1px 6px; border-radius: 6px; }
.coach.flash { animation: pop .45s cubic-bezier(.3, 1.8, .5, 1); }
.app.needs-name .tags { display: none; }
.arrive { animation: arrive .4s cubic-bezier(.2, 1.2, .4, 1) backwards; }
.remove-friend svg { width: 14px; height: 14px; display: block; margin: auto; }

/* Vibe chips */
.tags {
  display: flex; gap: 7px; margin: 6px -14px 0; padding: 4px 14px 6px; overflow-x: auto; scrollbar-width: none;
  overscroll-behavior-x: contain; scroll-padding: 0 30px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 30px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 30px), transparent);
}
.tags::-webkit-scrollbar { display: none; }
.tag {
  flex: none; height: 34px; padding: 0 12px; border: 2px solid var(--ink); border-radius: 99px; background: #fff;
  font: 700 14px var(--ui); letter-spacing: -.2px; white-space: nowrap; box-shadow: 2px 2px 0 var(--ink);
  transition: background .15s, color .15s, box-shadow .15s;
}
.tag { display: inline-flex; align-items: center; gap: 5px; }
.tag-emoji { font-size: 15px; }
.tag[aria-pressed="true"] { background: var(--ink); color: #fff; box-shadow: 2px 2px 0 var(--orange); }
.tag:active { transform: translate(1px, 1px); box-shadow: none; }
.tag.pop { animation: pop .4s cubic-bezier(.3, 1.8, .5, 1); }

/* Deck */
.deck { position: relative; flex: 1 1 auto; min-height: 0; margin: 12px 0 4px; }
.card {
  position: absolute; left: 50%; top: 50%;
  background: var(--ink); border: 3px solid var(--ink); border-radius: 18px; overflow: hidden; isolation: isolate;
  box-shadow: 0 14px 34px #3b2a1029, 4px 4px 0 var(--ink);
  transition: transform .42s cubic-bezier(.2, .9, .25, 1.12), opacity .3s;
  will-change: transform; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.card.is-top { cursor: grab; }
.card::after { content: ''; position: absolute; inset: 0; z-index: 4; background: var(--bg); opacity: .5; pointer-events: none; transition: opacity .3s; }
.card.is-top::after, .card.leaving::after { opacity: 0; }
.card.dragging, .deck.dragging .card { transition: none; }
.card.dragging { cursor: grabbing; }
.card-bg {
  position: absolute; inset: -36px; background: var(--ink) var(--bg-img) center / cover no-repeat;
  filter: blur(28px) saturate(1.4) brightness(.68); transform: scale(1.06); pointer-events: none;
}
.card.is-dna { background: var(--bg); }
.card.is-dna .meme-frame { box-shadow: none; }
.meme-frame { position: absolute; overflow: hidden; box-shadow: 0 6px 28px #0009; pointer-events: none; }
.card-img { position: absolute; left: 0; width: 100%; display: block; object-fit: fill; pointer-events: none; background: #222; }
.card-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.card-badge {
  position: absolute; bottom: 12px; left: 10px; z-index: 3; pointer-events: none;
  padding: 4px 10px; border: 2px solid var(--ink); border-radius: 99px;
  background: var(--yellow); color: var(--ink); box-shadow: 2px 2px 0 var(--ink);
  font: 700 11px var(--ui); letter-spacing: .3px; text-transform: uppercase;
}
.card-badge.is-live { background: #7dff6a; }
.card-badge.is-now { background: #8be0ff; }
.card-badge.is-dna { background: var(--yellow); }
.card-tools {
  position: absolute; right: 10px; bottom: 10px; z-index: 5; display: flex; gap: 6px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.card.is-top:not(.dragging) .card-tools { opacity: 1; pointer-events: auto; }
.card-tool {
  width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  border: 2px solid var(--ink); border-radius: 50%; background: #fffffff0; color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink); font-size: 16px; line-height: 1;
  transition: transform .12s, background .15s;
}
.card-tool:active { transform: scale(.9); }
.card.remix-pop .meme-frame { animation: pop .32s cubic-bezier(.3, 1.6, .5, 1); }
.stamp {
  position: absolute; top: 18%; z-index: 3; padding: 4px 14px 2px; border: 5px solid; border-radius: 12px;
  font: 400 clamp(30px, 9vw, 46px) Anton, Impact, sans-serif; letter-spacing: 1px; background: #ffffffee;
  opacity: 0; pointer-events: none;
}
.stamp-nah { right: 14px; color: var(--red); transform: rotate(14deg); }
.stamp-send { left: 14px; color: var(--green); transform: rotate(-14deg); }

/* Idle nudge: a hand that drags the top card to show the swipe. The fingertip sits on the anchor point. */
.swipe-hand { position: absolute; z-index: 40; width: 0; height: 0; pointer-events: none; }
.swipe-hand-ring { position: absolute; left: -19px; top: -19px; width: 38px; height: 38px; border-radius: 50%; background: #ffffff66; border: 2px solid #ffffffd9; opacity: 0; }
.swipe-hand-icon { position: absolute; left: -21px; top: -7px; font-size: 46px; line-height: 1; filter: drop-shadow(0 4px 8px #0006); }

/* First deal: cards drop in one after another */
.deck.deal .card:not(.leaving) { animation: deal .5s cubic-bezier(.2, 1.25, .4, 1) backwards; }
.deck.deal .card[data-pos="1"] { animation-delay: .09s; }
.deck.deal .card[data-pos="0"] { animation-delay: .18s; }
@keyframes deal { from { transform: translateY(70px) scale(.8) rotate(-8deg); opacity: 0; } }

/* Legendary drop: animated holo border */
@property --spin { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
.card.legendary {
  border-color: transparent;
  background: linear-gradient(var(--ink), var(--ink)) padding-box, conic-gradient(from var(--spin), #ffd700, #ff5a1f, #ff4fd8, #4fd2ff, #7dff6a, #ffd700) border-box;
  border-width: 5px;
  animation: spin 2.4s linear infinite;
  box-shadow: 0 0 34px #ffcf3a99, 4px 4px 0 var(--ink);
}

/* Prompt cards (add a friend / roast someone else) */
.card[data-kind="prompt"] { background: var(--yellow); display: flex; container-type: size; }
.prompt { margin: auto; padding: 26px 22px; text-align: center; width: 100%; }
.prompt-emoji { font-size: 60px; line-height: 1; }
.prompt h2 { font: 700 27px/1.12 var(--ui); letter-spacing: -1px; margin: 14px 0 8px; }
.prompt h2 .hl { background: #fff; padding: 0 6px; border-radius: 6px; }
.prompt p { margin: 0 0 16px; font-size: 16px; }
.prompt-form { display: flex; gap: 8px; }
.prompt-form input {
  flex: 1; min-width: 0; height: 50px; border: 2.5px solid var(--ink); border-radius: 12px; padding: 0 12px;
  font: 700 18px var(--ui); background: #fff; outline: 0;
}
.prompt-form button, .chips button {
  border: 2.5px solid var(--ink); border-radius: 12px; background: var(--ink); color: #fff; font: 700 16px var(--ui); padding: 0 16px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.chips button { background: #fff; color: var(--ink); height: 38px; font-size: 14px; padding: 0 12px; border-width: 2px; }
.prompt-skip { margin: 14px 0 0 !important; font-size: 13px !important; color: #6d5d1d; }
.prompt .prompt-or { margin: 14px 0 0; font: 600 13px var(--ui); color: #6d5d1d; }
.chips-vibe { margin-top: 8px; }
.chips-vibe button { border-radius: 99px; }
@container (max-height: 470px) {
  .prompt { padding: 16px 16px; }
  .prompt-emoji { font-size: 44px; }
  .prompt h2 { font-size: 23px; margin: 8px 0 4px; }
  .prompt p { margin-bottom: 12px; font-size: 15px; }
  .prompt-form input { height: 46px; }
  .chips { margin-top: 10px; gap: 6px; }
  .chips button { height: 34px; }
  .prompt .prompt-or { margin-top: 10px; }
  .chips-vibe { margin-top: 6px; }
}
@container (max-height: 380px) {
  .prompt-emoji { font-size: 34px; }
  .prompt h2 { font-size: 20px; }
  .prompt p { margin-bottom: 8px; font-size: 14px; }
}

/* Action buttons */
.actions { flex: none; display: flex; justify-content: center; align-items: center; gap: 14px; padding: 4px 0 2px; }
.act {
  height: 60px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 3px solid var(--ink); border-radius: 99px; box-shadow: 3px 4px 0 var(--ink);
  font: 700 19px var(--ui); letter-spacing: -.3px; transition: transform .1s, box-shadow .1s;
}
.act:active:not(:disabled) { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.act-next, .act-send { flex: 1 1 0; max-width: 170px; }
.act-next { background: #fff; }
.act-icon, .act svg { display: inline-flex; }
.act-next .act-icon svg { width: 19px; height: 19px; color: var(--red); }
.act-send { background: var(--green); color: #fff; }
.act-send .act-icon svg { width: 23px; height: 23px; }
.act-back { width: 50px; height: 50px; flex: none; background: #fff; padding: 0; }
.act-back svg { width: 23px; height: 23px; }
.act-back:disabled { opacity: .35; cursor: default; }
.hint { flex: none; margin: 8px 0 0; text-align: center; font: 500 12px var(--ui); color: var(--muted); }
.hint a { color: inherit; }
.hint-keys { display: none; }
@media (hover: hover) and (pointer: fine) {
  .hint-touch { display: none; }
  .hint-keys { display: inline; }
  .act:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 3px 6px 0 var(--ink); }
  .tag:hover:not([aria-pressed="true"]), .icon-btn:hover, .pill-btn:hover, .card-tool:hover { background: var(--yellow); }
}
@media (hover: hover) and (pointer: fine) {
  .tags { cursor: grab; }
  .tags.grabbing { cursor: grabbing; }
  .tags.grabbing .tag { pointer-events: none; }
}

/* Toast — floats cleanly above the bottom actions so it never covers vibe chips or captions */
.toast {
  position: fixed; left: 50%; bottom: var(--toast-bottom, 98px); z-index: 90;
  width: max-content; max-width: min(92vw, 440px); padding: 10px 16px; border-radius: 16px; background: var(--ink); color: #fff;
  font: 600 14px/1.35 var(--ui); text-align: center; box-shadow: 3px 3px 0 var(--orange);
  transform: translate(-50%, 10px) scale(.96); opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.confetti span { position: absolute; font-size: 30px; will-change: transform, opacity; }

/* Share sheet */
.sheet {
  border: 3px solid var(--ink); border-radius: 22px; background: var(--bg); color: var(--ink);
  width: min(420px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 18px; box-shadow: 5px 6px 0 var(--ink);
  overflow: auto;
}
.sheet::backdrop { background: #1414148c; backdrop-filter: blur(4px); }
.sheet[open] { animation: sheet-in .28s cubic-bezier(.2, 1.3, .4, 1); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px -4px 14px 2px; }
.icon-btn {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center; padding: 0; color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 50%; background: #fff; box-shadow: 2px 2px 0 var(--ink);
  transition: background .15s, transform .1s;
}
.icon-btn svg { width: 17px; height: 17px; display: block; }
.icon-btn:active { transform: translate(1px, 1px); box-shadow: none; }
.sheet-preview { display: grid; place-items: center; margin: 0 0 14px; min-height: 120px; }
.sheet-preview img { max-width: 100%; max-height: 36dvh; border: 2.5px solid var(--ink); border-radius: 12px; display: block; }
.sheet h2 { font: 700 21px/1.15 var(--ui); letter-spacing: -.7px; margin: 0; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.sh {
  display: flex; align-items: center; justify-content: center; height: 50px; border: 2.5px solid var(--ink); border-radius: 14px;
  background: #fff; font: 700 16px var(--ui); color: var(--ink); text-decoration: none; box-shadow: 2px 2px 0 var(--ink);
}
.sh:active { transform: translate(1px, 1px); box-shadow: none; }
.sheet.no-native #sh-link { grid-column: 1 / -1; }
.sh-wa { background: #25d366; color: #fff; grid-column: 1 / -1; height: 56px; font-size: 18px; }
.sheet-status { margin: 10px 0 0; text-align: center; font: 600 14px var(--ui); color: #0e7a40; }
.sheet-status:empty { display: none; }
.edit-fields { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.edit-field label { display: block; font: 700 12px var(--ui); color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 0 0 4px 2px; }
.edit-field textarea {
  width: 100%; min-height: 54px; padding: 9px 11px; border: 2.5px solid var(--ink); border-radius: 12px;
  background: #fff; font: 600 15px/1.3 var(--ui); resize: vertical; outline: 0;
}
.edit-tip { margin: 0 0 12px; font: 500 12px var(--ui); color: var(--muted); text-align: center; }
.edit-tip code { background: var(--yellow); color: var(--ink); padding: 1px 5px; border-radius: 5px; font-weight: 700; }
.sh-apply { background: var(--orange); color: #fff; }

/* Desktop gets a bigger stage */
@media (min-width: 900px) {
  .deck::before, .deck::after { position: absolute; top: 50%; transform: translateY(-50%); font: 700 18px var(--ui); color: #b5aa96; pointer-events: none; }
  .deck::before { content: '← nah'; left: -70px; }
  .deck::after { content: 'send →'; right: -78px; }
  .app { max-width: 620px; padding-top: 18px; padding-bottom: 16px; }
  .logo { font-size: 27px; }
  .names { min-height: 62px; }
  .name-input { font-size: 23px; }
  .act { height: 64px; font-size: 20px; }
  .act-next, .act-send { max-width: 200px; }
}
@media (max-height: 640px) {
  .hint { display: none; }
  .act { height: 52px; }
  .act-back { width: 44px; height: 44px; }
  .names { min-height: 50px; }
  .tag { height: 30px; font-size: 13px; padding: 0 10px; }
}
@media (max-width: 360px) {
  .add-friend { padding: 0 8px; font-size: 13px; }
  .name-input { font-size: 18px; }
}

@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25) rotate(-6deg); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 #ffe14a00; } 50% { box-shadow: 0 0 0 6px #ffe14acc; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
@keyframes spin { to { --spin: 360deg; } }
@keyframes arrive { from { opacity: 0; transform: translateY(-6px) scale(.96); } }
@keyframes pop { 40% { transform: scale(1.14) rotate(-4deg); } }
@keyframes sheet-in { from { transform: translateY(30px) scale(.96); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
