.life-race-emblem {
  position: relative;
  isolation: isolate;
  background: radial-gradient(ellipse at 50% 78%, #bf63f789, transparent 65%);
}
.life-race-emblem > span {
  position: absolute;
  inset: 0 auto auto 8%;
  z-index: -1;
  font-size: clamp(24px, 7vw, 46px);
  transform: rotate(-18deg);
}
.life-race-stage {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  gap: 14px;
  min-width: 0;
  padding: clamp(12px, 3vw, 24px);
  overflow: hidden;
  color: #fff2ff;
  text-align: center;
  border: 1px solid #9c61c6;
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 50% 100%, #653188 0%, transparent 76%),
    linear-gradient(160deg, #261442, #140e2c 54%, #2b174a);
  box-shadow: inset 0 1px 0 #f6bcff36, 0 10px 24px #13081e70;
}
.life-race-stage h2, .life-race-stage p { margin: 0; }
.life-race-stage h2 { font-size: clamp(20px, 5vw, 32px); }
.life-race-stage > button { width: min(100%, 400px); min-height: 48px; }
.life-race-stage > button:disabled { opacity: .55; }
.life-race-status { margin: 6px 0 0; text-align: center; color: #ead3ff; }
.life-race-status:empty { display: none; }
.life-race-count {
  padding: 6px 14px;
  border-radius: 100px;
  background: #a46bd32b;
  color: #f2ddff;
  font-weight: 700;
}
.life-race-muted { font-size: 13px; color: #e2c9ef; }
.life-race-flags {
  font-size: 53px;
  line-height: 1.2;
  transform: rotate(-8deg);
  filter: drop-shadow(0 4px 16px #cb70ff);
}
.life-race-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 2vw, 14px);
  width: min(100%, 500px);
}
.life-race-slot {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 5px;
  padding: 8px 4px 10px;
  min-width: 0;
  border-radius: 16px;
  border: 1px solid #c880fa;
  background: radial-gradient(ellipse at center 85%, #9b59d659, #281846);
  box-shadow: inset 0 0 12px #ca76ff44;
}
.life-race-slot.empty { border-color: #8051a4; }
.life-race-slot > strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(11px, 2.7vw, 15px);
}
.life-race-slot > small { color: #e8c9ff; font-size: 11px; }
.life-race-slot > .life-character, .life-race-slot > .life-race-silhouette {
  width: min(100%, 105px);
  height: clamp(60px, 17vw, 104px);
  object-fit: contain;
}
.life-race-silhouette {
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #100c28, #4a2866);
  clip-path: polygon(14% 12%, 34% 25%, 67% 25%, 87% 12%, 91% 48%, 96% 66%, 82% 85%, 65% 91%, 34% 91%, 16% 85%, 4% 66%, 9% 47%);
  color: #d686fa;
  text-shadow: 0 0 10px #da78f0;
  font-size: 27px;
  font-weight: 900;
}
.life-race-hud {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  text-align: left;
  gap: 8px 12px;
  width: 100%;
}
.life-race-timer {
  padding: 5px 11px;
  border: 1px solid #ad76d2;
  border-radius: 100px;
  background: #221438;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.life-race-meter {
  grid-column: 1 / -1;
  appearance: none;
  width: 100%;
  height: 13px;
  border: 1px solid #cd82ee;
  border-radius: 100px;
  background: #1e1136;
  overflow: hidden;
}
.life-race-meter::-webkit-progress-bar { background: #1e1136; }
.life-race-meter::-webkit-progress-value { background: linear-gradient(90deg, #7842de, #f790eb); }
.life-race-meter::-moz-progress-bar { background: linear-gradient(90deg, #7842de, #f790eb); }
.life-race-field {
  --runner: clamp(50px, 13vw, 92px);
  --runner-half: clamp(25px, 6.5vw, 46px);
  --name-half: clamp(50px, 16vw, 70px);
  --lane-height: clamp(82px, 17vw, 116px);
  position: relative;
  width: 100%;
  padding: clamp(45px, 10vw, 77px) var(--runner-half) 12px;
  overflow: hidden;
  border: 1px solid #955dbd;
  border-radius: 19px;
  background:
    url('/miniapp/assets/life/theme-cloud-left.webp') left top / 33% 80px no-repeat,
    url('/miniapp/assets/life/theme-cloud-right.webp') right top / 33% 80px no-repeat,
    radial-gradient(ellipse 34% 46% at 97% 40%, #894bb6 43%, transparent 44%),
    radial-gradient(ellipse 46% 52% at 0% 36%, #5b3981 46%, transparent 47%),
    radial-gradient(circle at 68% 7%, #ffe4ff 1px, transparent 3px),
    radial-gradient(circle at 35% 12%, #e9baf6 1px, transparent 3px),
    radial-gradient(ellipse at 50% 28%, #723e9a, transparent 65%),
    linear-gradient(#1f163e, #422866);
}
.life-race-lane {
  --distance: 0%;
  position: relative;
  height: var(--lane-height);
}
.life-race-lane::before {
  position: absolute;
  inset: 0 calc(-1 * var(--runner-half));
  content: '';
  border-top: 2px solid #f9b0ff91;
  background: linear-gradient(165deg, #7b51a8, #4a306d 66%, #513577);
  box-shadow: inset 0 5px 10px #d38bf03d;
}
.life-race-lane.own::before { background: linear-gradient(165deg, #925bbb, #5a3784 66%, #694298); }
.life-race-start-line, .life-race-finish {
  position: absolute;
  z-index: 1;
  bottom: 12px;
  height: calc(var(--lane-height) * 3);
  pointer-events: none;
}
.life-race-start-line {
  left: var(--runner-half);
  border-left: 2px dashed #f9d5ff8c;
}
.life-race-finish {
  right: var(--runner-half);
  width: 12px;
  background: repeating-conic-gradient(#ffecffab 0 25%, #301b52aa 0 50%) 50% / 12px 12px;
}
.life-race-finish::before {
  position: absolute;
  bottom: 100%;
  right: -13px;
  content: '🏁';
  font-size: 26px;
}
.life-race-chevron {
  position: absolute;
  top: 47%;
  left: 21%;
  width: 16px;
  height: 16px;
  transform: rotate(-45deg);
  border: solid #e9adff63;
  border-width: 0 3px 3px 0;
}
.life-race-chevron:nth-child(2) { left: 49%; }
.life-race-chevron:nth-child(3) { left: 76%; }
.life-race-runner {
  position: absolute;
  z-index: 2;
  bottom: 16px;
  left: var(--distance);
  width: var(--runner);
  transform: translateX(-50%);
  transition: left 145ms linear;
  pointer-events: none;
}
.life-race-runner-art {
  position: relative;
  display: grid;
  place-items: center;
  height: calc(var(--lane-height) - 23px);
  filter: drop-shadow(0 6px 4px #1a0e2ebc);
}
.life-race-runner-art > .life-character {
  width: 100%;
  height: 100%;
  max-height: calc(var(--lane-height) - 23px);
  object-fit: contain;
}
.life-race-runner.running .life-race-runner-art { animation: life-race-stride .26s linear infinite; }
.life-race-runner.running .life-race-runner-art::after {
  position: absolute;
  bottom: 2px;
  left: 30%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #f4cbff;
  box-shadow: -5px 0 #e4a4fa, -9px 2px #b879db;
  content: '';
  animation: life-race-dust .26s linear infinite;
}
.life-race-runner.pushes .life-race-runner-art { animation: life-race-lunge .3s ease; }
.life-race-runner.offline .life-race-runner-art { opacity: .5; }
.life-race-name {
  --inset: calc(var(--name-half) - var(--runner-half) + 3px);
  position: absolute;
  z-index: 2;
  bottom: 3px;
  left: clamp(var(--inset), var(--distance), calc(100% - var(--inset)));
  display: block;
  width: max-content;
  max-width: calc(2 * var(--name-half));
  padding: 0 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f8e3ff;
  font-size: 10px;
  font-weight: 800;
  text-shadow: 0 1px 3px #1a0d2c;
  transform: translateX(-50%);
  transition: left 145ms linear;
}
.life-race-lane.own .life-race-name { color: #fff; background: #3f215e; border-radius: 20px; }
.life-race-start {
  position: absolute;
  z-index: 3;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(28px, 8vw, 50px);
  font-weight: 950;
  line-height: 1;
  color: #ffdcff;
  text-shadow: 0 0 18px #ec81ff, 0 2px 1px #9434b5;
  pointer-events: none;
}
.life-race-effect {
  position: absolute;
  top: -7px;
  left: 0;
  width: 100%;
  opacity: 0;
  color: #ffebf9;
  font-size: 15px;
  font-weight: 950;
  text-shadow: 0 0 6px #ff2487, 0 1px 2px #30162d;
}
.life-race-runner.hit .life-race-effect, .life-race-runner.miss .life-race-effect { animation: life-race-impact .3s ease-out; }
.life-race-runner.hit .life-race-runner-art { animation: life-race-flash .3s ease-out; }
.life-race-controls {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(82px, 3fr);
  gap: 8px;
  width: 100%;
}
.life-race-controls > button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: clamp(62px, 13vw, 82px);
  padding: 4px;
  border: 1px solid #e6a5ff;
  border-radius: 15px;
  color: #fff;
  font: inherit;
  font-size: clamp(15px, 4vw, 23px);
  font-weight: 850;
  touch-action: manipulation;
  user-select: none;
  cursor: pointer;
}
.life-race-controls .life-race-run {
  background: linear-gradient(#bf6cf0, #793bc8 75%);
  box-shadow: inset 0 2px 8px #ffd6ff80, 0 3px 0 #5a259b;
}
.life-race-paw {
  width: 22px;
  height: 22px;
  background: currentColor;
  mask: url('/miniapp/assets/pets/paw.png') center / contain no-repeat;
}
.life-race-controls .life-race-push {
  flex-direction: column;
  gap: 1px;
  border-color: #ffadf4;
  background: linear-gradient(#ed6ac7, #a62c81 75%);
  box-shadow: inset 0 2px 8px #ffe6fc78, 0 3px 0 #78215f;
  font-size: clamp(12px, 3vw, 17px);
}
.life-race-controls > button:disabled { opacity: .55; cursor: default; }
.life-race-controls > button:active:not(:disabled) { transform: translateY(2px); filter: brightness(1.15); }
.life-race-controls > button:focus-visible { outline: 3px solid white; outline-offset: 2px; }
.life-race-controls small { font-size: 10px; }
.life-race-result-title {
  z-index: 1;
  color: #ffe7ff;
  text-shadow: 0 0 17px #ee82f7;
}
.life-race-winner {
  position: relative;
  display: grid;
  place-items: center;
  width: min(65vw, 230px);
  aspect-ratio: 1.15;
  background: radial-gradient(ellipse, #bf62e48c, transparent 71%);
}
.life-race-winner .life-character { width: 100%; height: 100%; object-fit: contain; }
.life-race-cup { position: absolute; top: 2%; right: 4%; font-size: 44px; filter: drop-shadow(0 0 12px #ffa735); }
.life-race-prize {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px 12px;
  padding: 10px 20px;
  border: 1px solid #ce8cfa;
  border-radius: 14px;
  background: #2b184c;
  text-align: left;
}
.life-race-confetti { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
.life-race-confetti i {
  position: absolute;
  top: -12px;
  left: calc(3% + var(--piece) * 4.9%);
  width: 7px;
  height: 11px;
  background: #ffcb70;
  animation: life-race-confetti 1.8s ease-in calc(var(--piece) * 22ms) both;
}
.life-race-confetti i:nth-child(3n) { background: #f7a2ff; }
.life-race-confetti i:nth-child(3n + 1) { background: #ae83f8; }
@keyframes life-race-stride {
  25% { transform: translateY(-4px) rotate(-3deg) scaleX(1.04); }
  75% { transform: translateY(-2px) rotate(3deg) scaleY(.94); }
}
@keyframes life-race-lunge { 45% { transform: translateX(4px) rotate(11deg); } }
@keyframes life-race-dust { to { transform: translate(-12px, -4px); opacity: 0; } }
@keyframes life-race-impact {
  0%, 60% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-17px); }
}
@keyframes life-race-flash {
  45% { filter: drop-shadow(0 0 10px #ff64c4) brightness(1.4); transform: rotate(-10deg); }
}
@keyframes life-race-confetti {
  to { transform: translate(25px, 430px) rotate(450deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .life-race-stage *, .life-race-stage *::before { animation-duration: 0s !important; transition-duration: 0s !important; }
  .life-race-runner.hit .life-race-effect, .life-race-runner.miss .life-race-effect { opacity: 1; }
}
