/* two people at an event swapping name tags: paper, ink, one sharpie-red accent */
:root {
  --paper: #f4eee3;
  --paper-raised: #fbf8f2;
  --ink: #221d18;
  --ink-secondary: rgba(34, 29, 24, 0.7);
  --ink-tertiary: rgba(34, 29, 24, 0.5);
  --ink-muted: rgba(34, 29, 24, 0.32);
  --rule: rgba(34, 29, 24, 0.13);
  --rule-soft: rgba(34, 29, 24, 0.07);
  --well: rgba(34, 29, 24, 0.045);
  --tag-red: #d4372c;
  --tag-red-pressed: #b72d23;
  --on-tag: #fffaf3;
  --ios-blue: #007aff;
  --space: 4px;
  --radius-small: 10px;
  --radius-card: 16px;
  --sticker-shadow: 0 1px 1px rgba(34, 29, 24, 0.06), 0 6px 18px -8px rgba(34, 29, 24, 0.28);
  --ui-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --marker-font: "Permanent Marker", "Marker Felt", cursive;
  --mono-font: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--ui-font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

#app {
  max-width: 420px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + var(--space) * 5) calc(var(--space) * 5) calc(env(safe-area-inset-bottom) + var(--space) * 8);
}

.wordmark { display: flex; align-items: center; gap: calc(var(--space) * 2); font-weight: 700; letter-spacing: -0.02em; font-size: 17px; }
.wordmark svg { width: 30px; height: 18px; }
.wordmark circle { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.wordmark circle:last-child { stroke: var(--tag-red); }

.screen { display: none; }
#app[data-screen="home"] #home-screen,
#app[data-screen="room"] #room-screen { display: flex; flex-direction: column; }

h1 { font-size: 34px; line-height: 1.05; letter-spacing: -0.035em; font-weight: 750; margin: calc(var(--space) * 14) 0 calc(var(--space) * 3); }
.lede { margin: 0 0 calc(var(--space) * 8); color: var(--ink-secondary); font-size: 16px; line-height: 1.4; }

.primary, .secondary {
  border: 0; border-radius: var(--radius-small); min-height: 52px; padding: 0 calc(var(--space) * 5);
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em; transition: transform 120ms ease-out, background 120ms ease-out;
}
.primary { background: var(--tag-red); color: var(--on-tag); display: flex; align-items: center; justify-content: center; }
.primary:active { background: var(--tag-red-pressed); transform: scale(0.985); }
.secondary { background: var(--ink); color: var(--paper); }
.secondary:active { transform: scale(0.97); }
.text-button { background: none; border: 0; color: var(--ink-tertiary); font-size: 15px; padding: calc(var(--space) * 3); margin-top: calc(var(--space) * 6); align-self: center; }

.divider { display: flex; align-items: center; gap: calc(var(--space) * 3); color: var(--ink-tertiary); font-size: 13px; margin: calc(var(--space) * 7) 0 calc(var(--space) * 4); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

.join { display: flex; gap: calc(var(--space) * 2); }
.join input {
  flex: 1; min-width: 0; min-height: 52px; border-radius: var(--radius-small); border: 1px solid var(--rule); background: var(--well);
  text-align: center; font-family: var(--marker-font); font-size: 26px; letter-spacing: 0.18em; text-transform: uppercase; padding: 0;
}
.join input::placeholder { color: var(--ink-muted); }
.join input:focus, .own-number input:focus { outline: none; border-color: var(--ink-secondary); background: var(--paper-raised); }

.own-number { display: flex; flex-direction: column; gap: calc(var(--space) * 1.5); margin-top: calc(var(--space) * 9); }
.own-number span { font-size: 13px; font-weight: 600; color: var(--ink-secondary); }
.own-number input { min-height: 44px; border-radius: var(--radius-small); border: 1px solid var(--rule); background: var(--well); padding: 0 calc(var(--space) * 3); font-size: 16px; }
.own-number small { color: var(--ink-tertiary); font-size: 12px; }

.error { color: var(--tag-red); font-size: 14px; min-height: 1em; margin: calc(var(--space) * 3) 0 0; }
.fine { color: var(--ink-tertiary); font-size: 12px; line-height: 1.45; }

/* the room code is written on a hello-my-name-is sticker so it reads across a table */
.name-tag {
  margin: calc(var(--space) * 7) auto 0; width: 100%; background: var(--paper-raised); border-radius: var(--radius-card);
  overflow: hidden; box-shadow: var(--sticker-shadow); transform: rotate(-1.2deg);
}
.name-tag-band { background: var(--tag-red); color: var(--on-tag); text-align: center; padding: calc(var(--space) * 2.5) 0 calc(var(--space) * 2); }
.name-tag-band strong { display: block; font-size: 30px; font-weight: 850; letter-spacing: 0.06em; line-height: 1; }
.name-tag-band span { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
.name-tag-code { font-family: var(--marker-font); font-size: 64px; letter-spacing: 0.14em; text-align: center; padding: calc(var(--space) * 4) 0 calc(var(--space) * 5); line-height: 1; padding-left: 0.14em; }

/* signature: the two circles drift together as the room fills, the overlap is the answer */
.venn { position: relative; height: 150px; margin: calc(var(--space) * 9) 0 calc(var(--space) * 2); }
.circle {
  position: absolute; top: 0; width: 150px; height: 150px; border-radius: 50%; border: 1.5px dashed var(--ink-muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: left 700ms cubic-bezier(0.2, 0.8, 0.2, 1), right 700ms cubic-bezier(0.2, 0.8, 0.2, 1), background 400ms ease-out, border-color 400ms ease-out;
}
.circle span { font-size: 15px; font-weight: 650; }
.circle em { font-style: normal; font-size: 12px; color: var(--ink-tertiary); min-height: 1em; }
.circle.you { left: 0; border-style: solid; border-color: var(--ink); }
.circle.them { right: 0; color: var(--ink-muted); }
.venn[data-stage="paired"] .circle.them, .venn[data-stage="done"] .circle.them { border-style: solid; border-color: var(--tag-red); color: var(--ink); }
.venn.you-ready .circle.you { background: rgba(34, 29, 24, 0.05); }
.venn.them-ready .circle.them { background: rgba(212, 55, 44, 0.07); }
.venn[data-stage="done"] .circle.you { left: calc(50% - 107px); }
.venn[data-stage="done"] .circle.them { right: calc(50% - 107px); }
.venn[data-stage="done"] .circle span { transform: translateX(var(--label-shift)); }
.venn[data-stage="done"] .circle.you { --label-shift: -34px; }
.venn[data-stage="done"] .circle.them { --label-shift: 34px; }
.venn[data-stage="done"] .circle em { opacity: 0; }
.overlap-count {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.6); opacity: 0;
  font-family: var(--marker-font); font-size: 34px; color: var(--tag-red); transition: opacity 300ms ease-out 500ms, transform 300ms ease-out 500ms;
}
.venn[data-stage="done"] .overlap-count { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.status { text-align: center; color: var(--ink-secondary); font-size: 15px; min-height: 1.3em; margin: calc(var(--space) * 4) 0; }

/* results read like a page torn from an address book */
.results { margin-top: calc(var(--space) * 2); }
.results h2 { font-size: 24px; letter-spacing: -0.03em; margin: 0 0 calc(var(--space) * 3); }
.letter { font-size: 12px; font-weight: 700; color: var(--tag-red); padding: calc(var(--space) * 4) 0 calc(var(--space) * 1); border-bottom: 1px solid var(--rule); }
.person { display: flex; flex-direction: column; gap: 2px; padding: calc(var(--space) * 3) 0; border-bottom: 1px solid var(--rule-soft); }
.person-name { font-size: 17px; }
.person-via { font-family: var(--mono-font); font-size: 12px; color: var(--ink-tertiary); }

/* mirrors the native ios permission alert */
.alert-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.32); display: flex; align-items: center; justify-content: center; z-index: 10; animation: fade-in 180ms ease-out; }
.alert {
  width: 270px; border-radius: 14px; overflow: hidden; background: rgba(242, 242, 247, 0.86);
  backdrop-filter: blur(24px) saturate(1.8); -webkit-backdrop-filter: blur(24px) saturate(1.8); color: #000; text-align: center;
  animation: alert-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.alert-body { padding: 19px 16px 18px; }
.alert h3 { margin: 0 0 4px; font-size: 17px; font-weight: 600; line-height: 1.3; letter-spacing: -0.02em; }
.alert p { margin: 0; font-size: 13px; line-height: 1.35; }
.alert-actions { display: flex; border-top: 0.5px solid rgba(60, 60, 67, 0.36); }
.alert-actions button { flex: 1; background: none; border: 0; min-height: 44px; font-size: 17px; color: var(--ios-blue); }
.alert-actions button + button { border-left: 0.5px solid rgba(60, 60, 67, 0.36); }
.alert-actions button.bold { font-weight: 600; }
.alert-actions button:active { background: rgba(0, 0, 0, 0.06); }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(34, 29, 24, 0.3); display: flex; align-items: flex-end; z-index: 11; animation: fade-in 180ms ease-out; }
.sheet {
  width: 100%; max-width: 420px; margin: 0 auto; background: var(--paper-raised); border-radius: 18px 18px 0 0;
  padding: calc(var(--space) * 3) calc(var(--space) * 5) calc(env(safe-area-inset-bottom) + var(--space) * 5); display: flex; flex-direction: column;
  animation: sheet-in 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--rule); align-self: center; margin-bottom: calc(var(--space) * 4); }
.sheet h3 { margin: 0 0 calc(var(--space) * 2); font-size: 20px; letter-spacing: -0.02em; }
.sheet p { margin: 0; color: var(--ink-secondary); font-size: 15px; }
.sheet ol { margin: calc(var(--space) * 3) 0 calc(var(--space) * 5); padding-left: 22px; line-height: 1.7; font-size: 15px; }
.sheet .fine { margin-top: calc(var(--space) * 4); }
.sheet .text-button { margin-top: calc(var(--space) * 2); }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes alert-in { from { opacity: 0; transform: scale(1.12); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
