:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7d8bd;
  --ink: #653f4e;
  --quiet-ink: rgb(101 63 78 / 62%);
  --focus: #173fa8;
  --apricot: #f7d8bd;
  --blush: #f4b7b2;
  --shell: #ffdeda;
  --carmine: #d93657;
  --ultramarine: #2753bd;
  --yolk: #f5bf28;
  --chlorophyll: #4b873f;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(circle at 17% 15%, rgb(255 255 247 / 95%) 0 5%, rgb(255 249 232 / 62%) 17%, transparent 36%),
    radial-gradient(circle at 82% 74%, rgb(255 180 174 / 34%) 0 9%, transparent 34%),
    radial-gradient(circle at 65% 9%, rgb(253 221 144 / 31%) 0 5%, transparent 25%),
    linear-gradient(151deg, #fff7e6 0%, #f9dfc7 46%, #f3c8b4 100%);
  color: var(--ink);
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  content: "";
  pointer-events: none;
  filter: blur(44px);
}

body::before {
  top: 7%;
  left: 3%;
  width: min(32vw, 460px);
  aspect-ratio: 1.6;
  background: rgb(255 255 255 / 46%);
}

body::after {
  right: -8vw;
  bottom: 0;
  width: min(40vw, 580px);
  aspect-ratio: 1;
  background: rgb(226 102 124 / 10%);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  display: grid;
  min-width: 188px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgb(101 63 78 / 45%);
  border-radius: 24px;
  background: #fffbed;
  color: #4f3041;
  font: 650 11px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .06em;
  place-items: center;
  transform: translateY(-140%);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#experience,
#specimen {
  position: relative;
  width: 100%;
  min-width: 0;
  height: 100%;
}

#specimen {
  isolation: isolate;
}

#cell-field {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.field-mark,
.cell-copy {
  position: absolute;
  z-index: 7;
  margin: 0;
  color: var(--quiet-ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(8px, .72vw, 10px);
  font-weight: 680;
  letter-spacing: .13em;
  line-height: 1.4;
  pointer-events: none;
}

.field-mark--title {
  top: max(18px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
}

.field-mark--inheritance {
  right: max(20px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  text-transform: lowercase;
}

.cell-copy {
  top: 78%;
  left: 50%;
  width: max-content;
  max-width: min(82vw, 360px);
  color: rgb(88 47 67 / 66%);
  text-align: center;
  transform: translateX(-50%);
  transition: opacity 240ms ease, transform 340ms ease;
}

body[data-phase="LINEAGE_BLOOM"] .cell-copy,
body[data-phase="BLOOM_REPLAY"] .cell-copy {
  opacity: 0;
}

.field-bloom {
  opacity: .2;
  filter: url(#soft-fold);
}

.field-bloom--one {
  fill: #fffef3;
}

.field-bloom--two {
  fill: #ee9d9e;
  opacity: .1;
}

.field-fold {
  fill: none;
  stroke: rgb(118 70 84 / 8%);
  stroke-linecap: round;
  stroke-width: 2;
}

.membrane-shadow {
  fill: rgb(151 62 86 / 18%);
  filter: url(#membrane-depth);
}

.membrane {
  fill: url(#cytoplasm);
  stroke: url(#wet-rim);
  stroke-width: clamp(3px, .35vw, 6px);
  vector-effect: non-scaling-stroke;
}

.membrane-glint {
  fill: none;
  stroke: rgb(255 255 248 / 68%);
  stroke-width: clamp(1.5px, .17vw, 3px);
  vector-effect: non-scaling-stroke;
}

.internal-folds path {
  fill: none;
  stroke: rgb(144 58 83 / 14%);
  stroke-linecap: round;
  stroke-width: 9;
}

.internal-folds ellipse {
  fill: rgb(255 255 247 / 24%);
  filter: url(#soft-fold);
}

.spindle-fiber {
  fill: none;
  stroke: rgb(78 70 117 / 27%);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.spindle-fiber.is-taut {
  stroke: rgb(66 64 124 / 46%);
  stroke-width: 1.8;
}

.chromosome-ribbon {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 9;
  vector-effect: non-scaling-stroke;
}

.chromosome-ribbon:nth-child(1) { stroke: #b23669; }
.chromosome-ribbon:nth-child(2) { stroke: #2855b8; }
.chromosome-ribbon:nth-child(3) { stroke: #d77b31; }
.chromosome-ribbon:nth-child(4) { stroke: #6c438d; }

.pole {
  cursor: grab;
}

.pole:active {
  cursor: grabbing;
}

.pole-aura {
  fill: rgb(255 250 206 / 55%);
  stroke: rgb(153 63 79 / 24%);
  stroke-width: 1.5;
}

.pole-core {
  fill: #fff6ba;
  stroke: rgb(166 54 72 / 68%);
  stroke-width: 2.5;
  transition: fill 160ms ease, stroke-width 160ms ease;
  vector-effect: non-scaling-stroke;
}

.pole.is-active .pole-core {
  fill: #ffd84f;
  stroke: var(--carmine);
  stroke-width: 4;
}

.pole.is-armed .pole-aura {
  fill: rgb(255 227 80 / 64%);
  stroke: rgb(211 54 77 / 52%);
}

.pole-ray {
  stroke: rgb(128 55 77 / 58%);
  stroke-linecap: round;
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.pole-hit {
  fill: transparent;
  pointer-events: all;
}

.pole-key,
.input-cue {
  fill: rgb(86 52 67 / 69%);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .08em;
  pointer-events: none;
  user-select: none;
}

.input-cue {
  font-size: 8px;
  font-weight: 650;
  opacity: .64;
}

.input-cue--touch {
  font-size: 9px;
  letter-spacing: .1em;
}

.organelle {
  transform-box: fill-box;
  transform-origin: center;
}

.organelle--dart .organelle-body {
  fill: var(--carmine);
  stroke: #832845;
  stroke-width: 1.5;
}

.organelle--dart .organelle-fold {
  fill: none;
  stroke: #ffb5a6;
  stroke-linecap: round;
  stroke-width: 1.35;
}

.organelle--swell .organelle-body {
  fill: rgb(204 239 247 / 78%);
  stroke: #3f8fa7;
  stroke-width: 1.4;
}

.organelle--swell .organelle-glint {
  fill: rgb(255 255 255 / 72%);
}

.organelle--rotate .organelle-body {
  fill: var(--yolk);
  stroke: #bd721d;
  stroke-width: 1.35;
}

.organelle--rotate .organelle-dot {
  fill: var(--ultramarine);
}

.organelle--pulse .organelle-body {
  fill: var(--chlorophyll);
  stroke: #275f33;
  stroke-width: 1.25;
}

.organelle--pulse .organelle-hair {
  stroke: #39783c;
  stroke-linecap: round;
  stroke-width: 1.15;
}

.cleavage-line {
  fill: none;
  stroke: rgb(128 46 76 / 43%);
  stroke-dasharray: 5 8;
  stroke-linecap: round;
  stroke-width: 2.4;
  vector-effect: non-scaling-stroke;
}

.daughter-shell .daughter-membrane,
.lineage-shell .daughter-membrane {
  fill: url(#daughter-cytoplasm);
  stroke: url(#wet-rim);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
}

.daughter-shell .daughter-glint,
.lineage-shell .daughter-glint {
  fill: none;
  stroke: rgb(255 255 248 / 65%);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.daughter-shell,
.lineage-shell,
.behavior-shell,
.behavior-interior,
.pulse-wave,
.rotate-mass {
  transform-box: fill-box;
  transform-origin: center;
}

.lineage-shell {
  opacity: .94;
}

.lineage-tag {
  display: none;
}

.cilia-hair {
  fill: none;
  stroke: rgb(64 116 55 / 62%);
  stroke-linecap: round;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.is-behaving.behavior-dart .behavior-shell {
  animation: daughter-dart 2.7s cubic-bezier(.2, .78, .3, 1) infinite;
}

.is-behaving.behavior-swell .behavior-shell {
  animation: daughter-swell 3.2s ease-in-out infinite;
}

.is-behaving.behavior-rotate .behavior-interior {
  animation: daughter-rotate 5.4s cubic-bezier(.44, 0, .56, 1) infinite;
}

.is-behaving.behavior-pulse .daughter-membrane,
.is-behaving.behavior-pulse .daughter-glint {
  animation: daughter-pulse 2.45s ease-in-out infinite;
}

.is-behaving.behavior-pulse .cilia-hair {
  animation: cilia-pulse 1.18s ease-in-out infinite alternate;
}

.is-behaving.behavior-pulse .cilia-hair:nth-child(3n + 1) {
  animation-delay: -.18s;
}

.is-behaving.behavior-pulse .cilia-hair:nth-child(3n + 2) {
  animation-delay: -.36s;
}

.rotate-mass {
  fill: rgb(39 83 189 / 19%);
  stroke: rgb(190 111 28 / 48%);
  stroke-width: 2.4;
  vector-effect: non-scaling-stroke;
}

.pulse-wave {
  fill: none;
  stroke: rgb(75 135 63 / 62%);
  stroke-dasharray: 3 9;
  stroke-linecap: round;
  stroke-width: 4;
  opacity: 0;
  vector-effect: non-scaling-stroke;
}

.is-behaving.behavior-pulse .pulse-wave {
  animation: daughter-pulse-wave 2.45s ease-out infinite;
}

@keyframes daughter-dart {
  0%, 18%, 88%, 100% { transform: translate(0, 0) skewX(0deg); }
  34% { transform: translate(54px, -12px) skewX(-9deg); }
  58% { transform: translate(48px, -9px) skewX(3deg); }
  72% { transform: translate(12px, -2px) skewX(-2deg); }
}

@keyframes daughter-swell {
  0%, 14%, 92%, 100% { transform: scale(1); }
  40%, 66% { transform: scale(1.2, 1.16); }
}

@keyframes daughter-rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes daughter-pulse {
  0%, 12%, 100% { transform: scale(1); }
  34% { transform: scale(1.12, .86) rotate(-1deg); }
  58% { transform: scale(.94, 1.08) rotate(1deg); }
  78% { transform: scale(1.05, .95); }
}

@keyframes daughter-pulse-wave {
  0%, 16%, 100% { opacity: 0; transform: scale(.8); stroke-dashoffset: 30; }
  38% { opacity: .88; }
  72% { opacity: .16; transform: scale(1.18); stroke-dashoffset: 0; }
}

@keyframes cilia-pulse {
  from { stroke-width: 1.2; opacity: .44; }
  to { stroke-width: 2.6; opacity: .96; }
}

.wake {
  fill: none;
  stroke: rgb(214 55 83 / 20%);
  stroke-linecap: round;
  stroke-width: 5;
  opacity: 0;
}

.is-behaving.behavior-dart .wake {
  animation: wake 2.7s ease-out infinite;
}

@keyframes wake {
  0%, 18%, 100% { opacity: 0; transform: translateX(8px) scaleX(.72); }
  36% { opacity: .9; transform: translateX(-24px) scaleX(1.15); }
  68% { opacity: .38; transform: translateX(-52px) scaleX(1.42); }
  84% { opacity: 0; transform: translateX(-72px) scaleX(1.55); }
}

.relative-line {
  fill: none;
  stroke: rgb(92 63 105 / 20%);
  stroke-dasharray: 2 9;
  stroke-linecap: round;
  stroke-width: 1.5;
  opacity: 0;
  vector-effect: non-scaling-stroke;
}

body[data-phase="LINEAGE_BLOOM"] .relative-line,
body[data-phase="BLOOM_REPLAY"] .relative-line {
  display: none;
}

@keyframes relatives {
  0% { opacity: 0; stroke-dashoffset: 28; }
  18% { opacity: .78; }
  68% { opacity: .34; }
  100% { opacity: .08; stroke-dashoffset: 0; }
}

.daughter-actions {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.daughter-choice {
  position: absolute;
  display: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 48%;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.daughter-choice.is-enabled {
  display: block;
}

.daughter-choice::after {
  position: absolute;
  right: 15%;
  bottom: 10%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgb(255 255 238 / 74%);
  box-shadow: 0 0 0 1px rgb(101 63 78 / 24%);
  content: "";
  opacity: .3;
  transition: opacity 160ms ease, transform 160ms ease;
}

.daughter-choice:hover::after,
.daughter-choice:focus-visible::after {
  opacity: 1;
  transform: scale(1.45);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.daughter-choice:focus-visible {
  border-color: var(--focus);
  outline: 0;
  box-shadow: 0 0 0 4px rgb(255 255 245 / 78%);
}

.ending {
  position: absolute;
  bottom: max(42px, calc(env(safe-area-inset-bottom) + 24px));
  left: 50%;
  z-index: 9;
  width: min(92vw, 440px);
  text-align: center;
  transform: translateX(-50%);
}

.ending[hidden] {
  display: none;
}

.ending p {
  margin: 0 0 10px;
  color: rgb(84 45 64 / 47%);
  font: 650 8px/1.3 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .16em;
}

.ending-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.ending button {
  min-width: 104px;
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid rgb(105 54 72 / 28%);
  border-radius: 999px;
  background: rgb(255 249 229 / 68%);
  box-shadow: inset 0 1px rgb(255 255 255 / 74%);
  color: rgb(86 46 65 / 82%);
  cursor: pointer;
  font: 690 10px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .05em;
  backdrop-filter: blur(7px);
}

.ending button:hover {
  background: rgb(255 253 240 / 92%);
}

.fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  overflow: hidden;
  padding: 28px;
  background:
    radial-gradient(circle at 15% 15%, #fffdf1 0 7%, transparent 34%),
    linear-gradient(145deg, #ffefda, #f4c1b3);
  place-items: center;
}

.fallback-date {
  position: absolute;
  top: 20px;
  left: 22px;
  margin: 0;
  font: 700 9px/1 ui-monospace, monospace;
  letter-spacing: .13em;
}

.fallback h1,
.fallback-ending {
  position: absolute;
  bottom: 90px;
  left: 50%;
  margin: 0;
  font: 680 12px/1 ui-monospace, monospace;
  letter-spacing: .12em;
  transform: translateX(-50%);
}

.fallback-ending {
  bottom: 68px;
  margin: 0;
  font-size: 10px;
}

.fallback-family {
  position: relative;
  width: min(920px, 92vw);
  height: min(620px, 72vh);
}

.fallback-cell {
  position: absolute;
  display: grid;
  width: clamp(128px, 20vw, 240px);
  aspect-ratio: 1.22;
  border: 4px solid rgb(147 62 85 / 38%);
  border-radius: 47% 53% 56% 44% / 55% 44% 56% 45%;
  background: radial-gradient(circle at 35% 25%, #fffdf0, rgb(247 175 171 / 76%));
  box-shadow: 0 18px 40px rgb(135 61 80 / 16%), inset 5px 6px 16px rgb(255 255 255 / 48%);
  place-items: center;
}

.fallback-cell b {
  position: absolute;
  bottom: 12%;
  font: 700 9px/1 ui-monospace, monospace;
  letter-spacing: .1em;
}

.fallback-cell--dart { top: 4%; left: 3%; transform: rotate(-5deg); }
.fallback-cell--swell { top: 9%; right: 7%; transform: scale(1.12) rotate(4deg); }
.fallback-cell--rotate { bottom: 3%; left: 31%; transform: rotate(9deg); }
.fallback-cell--pulse { right: 2%; bottom: 0; transform: scale(.84) rotate(-7deg); }

.fallback-motif {
  display: block;
  width: 34px;
  height: 24px;
}

.motif-bean { border: 6px double #a62c4d; border-radius: 50%; background: var(--carmine); }
.motif-vacuole { width: 34px; height: 34px; border: 3px solid #4e9bb0; border-radius: 50%; background: #d8f5fb; }
.motif-pigment { border: 6px dotted var(--ultramarine); border-radius: 50%; background: var(--yolk); }
.motif-cilia { border: 8px dashed #3c7c3b; border-radius: 50%; background: var(--chlorophyll); }

.fallback-note {
  position: absolute;
  bottom: 25px;
  left: 50%;
  width: min(88vw, 540px);
  margin: 0;
  text-align: center;
  font: 600 10px/1.45 ui-monospace, monospace;
  letter-spacing: .05em;
  transform: translateX(-50%);
}

@media (max-width: 560px) {
  .field-mark--title {
    top: max(13px, env(safe-area-inset-top));
    left: 50%;
    width: max-content;
    transform: translateX(-50%);
  }

  .field-mark--inheritance {
    right: 50%;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: max-content;
    transform: translateX(50%);
  }

  .cell-copy {
    top: auto;
    bottom: max(44px, calc(env(safe-area-inset-bottom) + 38px));
    font-size: 8px;
  }

  .ending {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(38px, calc(env(safe-area-inset-bottom) + 32px));
    left: max(14px, env(safe-area-inset-left));
    display: grid;
    width: auto;
    min-height: 82px;
    align-content: end;
    transform: none;
  }

  .ending p {
    margin-bottom: 10px;
  }

  .ending-actions {
    display: grid;
    grid-template-columns: minmax(104px, .82fr) minmax(148px, 1.18fr);
    gap: 8px;
    width: min(100%, 352px);
    margin-inline: auto;
  }

  .ending button {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding-inline: 11px;
  }

  .fallback-family {
    height: 68vh;
  }

  .fallback-cell {
    width: clamp(105px, 38vw, 155px);
  }

  .fallback-cell--dart { top: 2%; left: -3%; }
  .fallback-cell--swell { top: 15%; right: -2%; }
  .fallback-cell--rotate { bottom: 10%; left: 6%; }
  .fallback-cell--pulse { right: 0; bottom: 1%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }

  .is-behaving.behavior-dart .behavior-shell { transform: translate(38px, -8px) skewX(-7deg); }
  .is-behaving.behavior-dart .wake { opacity: .72; transform: translateX(-38px) scaleX(1.35); }
  .is-behaving.behavior-swell .behavior-shell { transform: scale(1.18, 1.14); }
  .is-behaving.behavior-rotate .behavior-interior { transform: rotate(46deg); }
  .is-behaving.behavior-pulse .daughter-membrane,
  .is-behaving.behavior-pulse .daughter-glint { transform: scale(1.1, .86) rotate(-1deg); }
  .is-behaving.behavior-pulse .pulse-wave { opacity: .78; transform: scale(1.12); }
  .is-behaving.behavior-pulse .cilia-hair { stroke-width: 2.8; opacity: .96; }
  body[data-phase="LINEAGE_BLOOM"] .relative-line,
  body[data-phase="BLOOM_REPLAY"] .relative-line { display: none; }
}
