:root {
  --navy: #031b36;
  --cyan: #2bccff;
  --welcome: #12b76a;
  --again: #f79009;
  --denied: #f04438;
  --offline: #344054;
  --pending: #7c3aed;
  --pending-text: #b39bff;
  --sheet: #0e1828;
  --line: rgba(255, 255, 255, 0.12);
  --muted: rgba(226, 234, 255, 0.62);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--navy);
  color: #fff;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.45; cursor: default; }
[hidden] { display: none !important; }
svg { display: block; }

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.big { width: 46px; height: 46px; stroke-width: 1.8; }

.glass {
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
}

/* Scanner */

.scanner { position: fixed; inset: 0; display: flex; flex-direction: column; }

.camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--navy);
}

/* Keeps the text readable over a bright camera image. */
.shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(0, 0, 0, 0.7), transparent calc(var(--top) + 220px)),
    linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent calc(var(--bottom) + 240px));
}

.top, .middle, .bottom { position: relative; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--top) + 10px) 22px 0;
}
.kicker { display: block; font-size: 13px; font-weight: 900; letter-spacing: 2.5px; color: var(--cyan); }
.top h1 { margin: 2px 0 0; font-size: 30px; font-weight: 700; line-height: 1.15; }

.count {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 64px;
  padding: 8px 12px;
  border-radius: 18px;
}
.count-n { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.count-n b { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.count-n small { margin-top: 3px; font-size: 11px; font-weight: 900; letter-spacing: 1.5px; opacity: 0.75; }
.count.bump b { animation: bump 0.35s ease-out; }
.chev {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.6;
}

.middle { flex: 1; display: grid; place-items: center; min-height: 0; }

.reticle {
  position: relative;
  width: min(270px, 70vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  animation: breathe 2.6s ease-in-out infinite;
}
.reticle svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: #fff;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
  transition: stroke 0.15s;
}
.reticle.checking svg { stroke: var(--cyan); }
.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  visibility: hidden;
  animation: spin 0.8s linear infinite;
}
.reticle.checking .spinner { visibility: visible; }

.camera-off {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 320px;
  padding: 0 24px;
  text-align: center;
}
.camera-off h2 { margin: 6px 0 0; font-size: 24px; font-weight: 700; }
.camera-off p { margin: 0 0 10px; color: var(--muted); font-size: 16px; }
.camera-off .btn { flex: none; min-width: 180px; }

.bottom { display: grid; gap: 14px; padding: 0 22px calc(var(--bottom) + 18px); }
.hint {
  min-height: 24px;
  margin: 0;
  text-align: center;
  font-size: 19px;
  font-weight: 600;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}
.controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.round { width: 54px; height: 54px; flex: none; display: grid; place-items: center; border-radius: 50%; }
.round.on { background: #fff; color: var(--navy); }
.round.unavailable { visibility: hidden; }
.find {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
}
.round:active, .find:active, .count:active { transform: scale(0.96); }

/* Result: the answer the door can read from across the room. */

.result {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--top) + 12px) 24px calc(var(--bottom) + 12px);
  background: var(--tint);
  animation: fade 0.15s ease-out;
}
.result.welcome { --tint: var(--welcome); }
.result.alreadyIn { --tint: var(--again); }
.result.notInvited { --tint: var(--denied); }
.result.pending { --tint: var(--pending); }
.result.failed { --tint: var(--offline); }
.result .spacer { flex: 1 1 12px; }
.result .title {
  margin: 0;
  max-width: 100%;
  font-size: clamp(26px, 9vw, 36px);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}

.hero {
  position: relative;
  flex: none;
  width: 210px;
  height: 210px;
  margin-top: 28px;
  animation: pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.hero .avatar { width: 100%; height: 100%; border: 6px solid #fff; box-shadow: 0 6px 28px rgba(0, 0, 0, 0.2); }
.corner {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border: 5px solid var(--tint);
  border-radius: 50%;
  background: #fff;
  color: var(--tint);
  animation: pop 0.35s cubic-bezier(0.34, 1.8, 0.64, 1) 0.15s both;
}
.badge {
  flex: none;
  width: 150px;
  height: 150px;
  margin-top: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--tint);
  animation: pop 0.4s cubic-bezier(0.34, 1.7, 0.64, 1) both;
}
.mark {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 11;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mark.hourglass, .mark.offline { stroke-width: 8; }
.mark .draw { stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw 0.3s ease-out 0.15s forwards; }
.corner .mark .draw { animation-delay: 0.3s; }

.details { display: flex; flex-direction: column; align-items: center; max-width: 100%; margin-top: 22px; text-align: center; }
.name {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: clamp(24px, 8.4vw, 32px);
  font-weight: 700;
  line-height: 1.12;
  overflow-wrap: anywhere;
}
.user { margin-top: 4px; font-size: 19px; font-weight: 500; opacity: 0.85; overflow-wrap: anywhere; }
.pill {
  margin-top: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 17px;
  font-weight: 700;
  animation: pop 0.25s ease-out both;
}
.message { max-width: 330px; margin: 0; font-size: 21px; font-weight: 600; opacity: 0.92; overflow-wrap: anywhere; }

.actions { display: flex; gap: 12px; width: 100%; max-width: 460px; margin-bottom: 12px; }
.btn {
  flex: 1;
  min-height: 56px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}
.btn.filled { background: #fff; color: var(--tint, var(--navy)); }
.btn.ghost { background: rgba(255, 255, 255, 0.18); color: #fff; }
.btn.narrow { flex: 0 0 112px; }
.btn.cyan { background: var(--cyan); color: var(--navy); }
.btn.big { width: 100%; min-height: 60px; font-size: 20px; }
.btn:active { opacity: 0.75; }

/* Sheets: Find creator and the guest list. */

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45); animation: fade 0.2s ease-out; }
.sheet-card {
  position: absolute;
  inset: calc(var(--top) + 10px) 0 0;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px 14px 0 0;
  background: var(--sheet);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.35);
  /* Fades in place: a sliding search field makes iOS scroll the page to where the field
     was mid-slide when the keyboard opens. */
  animation: sheet-in 0.22s ease-out;
}
.sheet-top { flex: none; touch-action: none; }
.grabber { width: 36px; height: 5px; margin: 6px auto 0; border-radius: 3px; background: rgba(255, 255, 255, 0.3); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 12px; }
.sheet-head h2 { margin: 0; overflow: hidden; font-size: 24px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.done { flex: none; padding: 8px 0 8px 12px; color: var(--cyan); font-size: 17px; font-weight: 600; }

.search {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  margin: 0 16px 10px;
  padding: 0 6px 0 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}
.search .icon { width: 20px; height: 20px; }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: none;
  color: #fff;
  font: 17px var(--font);
  -webkit-appearance: none;
  appearance: none;
  -webkit-user-select: text;
  user-select: text;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.clear { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); }
.clear svg { width: 20px; height: 20px; }
.clear circle { fill: currentColor; }
.clear path { fill: none; stroke: var(--sheet); stroke-width: 2.4; stroke-linecap: round; }

.rows-wrap {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--bottom) + 24px);
}
.rows { margin: 0; padding: 0; list-style: none; }
.rows li { position: relative; content-visibility: auto; contain-intrinsic-size: auto 66px; }
.rows li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 74px;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--line);
  transform: scaleY(0.5);
}
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 66px; padding: 9px 16px; text-align: left; }
button.row:active, .code-row:active { background: rgba(255, 255, 255, 0.07); }
.row .avatar { width: 46px; height: 46px; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-name { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.row-name b { overflow: hidden; font-size: 17px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.row-name .plus { flex: none; color: var(--welcome); font-size: 15px; font-weight: 700; }
.row-sub { overflow: hidden; color: var(--muted); font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.tag { flex: none; font-size: 13px; font-weight: 700; }
.tag.in { color: var(--welcome); }
.tag.pending { color: var(--pending-text); }
.tag.go { color: var(--cyan); }
.code-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 16px; color: var(--cyan); font-size: 17px; font-weight: 600; }

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: start center;
  justify-items: center;
  gap: 6px;
  padding: 14vh 28px 24px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}
.empty .icon { width: 44px; height: 44px; margin-bottom: 6px; stroke-width: 1.8; }
.empty h3 { margin: 0; color: #fff; font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.empty p { margin: 0; font-size: 15px; }

/* Avatars: the creator's photo so the door can match the face. */

.avatar {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}
.avatar .initials { font-weight: 700; line-height: 1; }
.avatar.small .initials { font-size: 16px; }
.avatar.big .initials { font-size: 70px; }
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.2s ease-out;
}
.avatar img.loaded { opacity: 1; }

/* Gate: the door code once per phone, then one tap to start. */

.gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: calc(var(--top) + 24px) 24px calc(var(--bottom) + 24px);
  background: radial-gradient(120% 70% at 50% 0%, #0b3a6b 0%, var(--navy) 62%);
}
.gate-body { display: grid; justify-items: center; gap: 14px; width: 100%; max-width: 360px; text-align: center; }
.gate-icon { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.gate h1 { margin: 4px 0 12px; font-size: 30px; font-weight: 800; }
.unlock { display: grid; gap: 12px; width: 100%; }
.code-label { color: var(--muted); font-size: 15px; font-weight: 600; }
.code {
  width: 100%;
  height: 64px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  outline: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: 700 30px var(--font);
  letter-spacing: 0.3em;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}
.code:focus { border-color: var(--cyan); }
.error { min-height: 22px; margin: 0; color: #ff8a80; font-size: 16px; font-weight: 600; }
.install-button { padding: 10px 14px; color: var(--cyan); font-size: 16px; font-weight: 600; }
.install-tip { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.noscript { position: fixed; inset: auto 0 40%; z-index: 40; text-align: center; }

/* A hidden switch: flipping it is the only way to tap the iPhone's haptics. */
.haptic { display: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes breathe { 50% { transform: scale(1.035); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bump { 40% { transform: scale(1.18); } }

@media (prefers-reduced-motion: reduce) {
  .reticle, .hero, .corner, .badge, .pill, .sheet-card, .count.bump b { animation: none; }
  .mark .draw { animation-duration: 0.01s; }
}
