:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #27313e;
  background: #fafbfc;
  font-synthesis: none;
  --pink: #e34b91;
  --blue: #4280d7;
  --duration: 1500ms;
  --travel-ease: cubic-bezier(0.65, 0, 0.35, 1);
}

* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; }

.page {
  min-height: 100svh;
  padding: 48px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.24em;
  margin: 0;
  font-family: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(48px, 6vw, 76px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.065em;
  white-space: nowrap;
}

.family-word { display: inline-flex; }
.segment, .letters { display: inline-block; }
.fam { color: var(--blue); }
.ily { color: var(--pink); }
.tree-word { color: #27313e; }

.is-rearranging .fam {
  animation: fam-travel var(--duration) var(--travel-ease) both;
}
.is-rearranging .ily {
  animation: ily-travel var(--duration) var(--travel-ease) both;
}
.is-rearranging .fam .letters {
  animation: fam-arc var(--duration) ease-in-out both;
}
.is-rearranging .ily .letters {
  animation: ily-arc var(--duration) ease-in-out both;
}

@keyframes fam-travel {
  from { transform: translateX(0); }
  to { transform: translateX(var(--fam-shift)); }
}
@keyframes ily-travel {
  from { transform: translateX(0); }
  to { transform: translateX(var(--ily-shift)); }
}
@keyframes fam-arc {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(0.5em) rotate(3deg); }
}
@keyframes ily-arc {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-0.5em) rotate(-3deg); }
}

.family-tree {
  align-self: center;
  margin: auto;
  padding: 76px 0 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #89949f;
}

.person {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 178px;
  min-height: 68px;
  padding: 16px 18px;
  border: 1px solid #e4e9ee;
  border-radius: 16px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
}

.avatar {
  position: relative;
  display: flex;
  align-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.avatar span {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: #e8edf2;
  border: 2px solid #fff;
}
.avatar span + span { position: absolute; left: 12px; background: #dce4ec; }
.stem { width: 1px; height: 42px; background: #dce3ea; }
.branches {
  position: relative;
  width: 204px;
  height: 55px;
  background: linear-gradient(#dce3ea, #dce3ea) center top / 1px 27px no-repeat;
}
.branches::after {
  content: "";
  position: absolute;
  top: 27px;
  left: 0;
  right: 0;
  height: 28px;
  border: 1px solid #dce3ea;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
}
.children { display: flex; gap: 26px; }
.child .avatar { width: 25px; }
.you { color: #687887; border-color: #dbe4ed; }
.you .avatar span { background: #dbe9f9; }

.replay {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 0;
  border: 0;
  background: transparent;
  color: #818c99;
  font-size: 13px;
  cursor: pointer;
  transition: color 180ms ease;
}
.replay svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.replay:hover { color: #27313e; }
.replay:focus-visible { outline: 2px solid var(--blue); outline-offset: 6px; border-radius: 3px; }

@media (max-width: 600px) {
  .page { padding: 28px 24px 20px; }
  .wordmark { font-size: clamp(38px, 12vw, 56px); }
  .family-tree { padding: 72px 0 56px; }
  .person { width: 144px; min-height: 64px; padding: 14px 12px; font-size: 12px; gap: 8px; }
  .children { gap: 18px; }
  .branches { width: 162px; }
}

@media (prefers-reduced-motion: reduce) {
  .is-rearranging .segment, .is-rearranging .letters { animation: none; }
  .is-rearranging .fam { transform: translateX(var(--fam-shift)); }
  .is-rearranging .ily { transform: translateX(var(--ily-shift)); }
  .replay { transition: none; }
}
