:root {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #26342c;
  background: #ebe9de;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }

#game { width: 100%; height: 100dvh; min-height: 340px; position: relative; overflow: hidden; }
#view, #fade, #targets { position: absolute; inset: 0; }
#view canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#view canvas:active { cursor: grabbing; }
#fade { pointer-events: none; background: #eee9dd; opacity: 0; transition: opacity 160ms ease; }
#game.shifting #fade { opacity: .92; }

.timeline {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: min(610px, calc(100% - 52px));
  height: 38px;
  pointer-events: none;
}

#track {
  --position: 89%;
  --mother-end: 45%;
  position: absolute;
  inset: 37px 0 auto;
  display: grid;
  grid-template-columns: var(--mother-end) 1fr;
  height: 2px;
}

.timeline-segment {
  position: relative;
  background: var(--role-color);
}

.timeline-segment[data-role="mother"] { --role-color: #306b54; }
.timeline-segment[data-role="daughter"] { --role-color: #a25439; }

.timeline-segment::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(50%, -50%);
  background: var(--role-color);
  z-index: 1;
}

.avatar {
  position: absolute;
  left: 50%;
  bottom: 9px;
  width: 28px;
  height: 28px;
  transform: translateX(-50%);
  overflow: hidden;
  border: 1px solid var(--role-color);
  border-radius: 50%;
  background: #f8f0df;
  color: var(--role-color);
}

.avatar::before {
  content: "";
  position: absolute;
  inset: 4px 6px 5px;
  border-radius: 47% 48% 38% 42%;
  background: #49352d;
}

.avatar::after {
  content: "";
  position: absolute;
  inset: 8px 0 0;
  background:
    radial-gradient(circle at 41% 28%, #49352d 0 .65px, transparent 1px),
    radial-gradient(circle at 60% 28%, #49352d 0 .65px, transparent 1px),
    radial-gradient(ellipse at 50% 26%, #e9b594 0 29%, transparent 31%),
    radial-gradient(ellipse at 50% 106%, currentColor 0 50%, transparent 52%);
}

.timeline-segment[data-role="mother"] .avatar::before {
  box-shadow: 3px 3px 0 -1px #49352d;
}

.timeline-segment[data-role="daughter"] .avatar::before {
  inset: 5px 8px 7px;
  box-shadow: -6px 5px 0 -2px #49352d, 6px 5px 0 -2px #49352d;
}

.timeline-segment[data-active="true"] .avatar {
  box-shadow: 0 0 0 2px var(--role-color);
}

#cursor {
  position: absolute;
  left: var(--position);
  top: 50%;
  width: 11px;
  height: 11px;
  transform: translate(-50%, -50%);
  border: 1px solid #fff8e9;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #2d312a;
  z-index: 2;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#error {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  width: calc(100% - 40px);
}

#targets { pointer-events: none; }
.target {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  width: 116px;
  height: 40px;
  padding: 0;
  background: transparent;
  color: transparent;
  border: 0;
}

.target:disabled { pointer-events: none; }
.target:focus-visible { outline: 1px solid #385749; outline-offset: 1px; }

@media (prefers-reduced-motion: reduce) {
  #fade { transition: none; }
}
