:root {
  --paper: #f3efe5;
  --surface: #fffdf8;
  --ink: #18201e;
  --muted: #69716d;
  --line: rgb(24 32 30 / 14%);
  --coral: #f06f52;
  --coral-dark: #a94330;
  --coral-soft: #ffe3da;
  --blue: #3978f2;
  --blue-dark: #2255b7;
  --blue-soft: #e5edff;
  --green: #159471;
  --yellow: #f3c64d;
  --shadow: 0 28px 80px rgb(47 43 34 / 13%);
  --travel-ease: cubic-bezier(0.5, 0, 0.9, 0.55);
  color-scheme: light;
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 3%, rgb(57 120 242 / 14%), transparent 30rem),
    radial-gradient(circle at 96% 8%, rgb(240 111 82 / 20%), transparent 34rem),
    linear-gradient(135deg, #eef2ec 0%, var(--paper) 52%, #ece3d8 100%);
}

button {
  color: inherit;
  font: inherit;
  cursor: pointer;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

h1,
h2,
h3,
p,
pre {
  margin: 0;
}

.page {
  width: min(1420px, calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 22px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  color: var(--coral-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.eyebrow::before {
  width: 18px;
  height: 9px;
  border: solid var(--coral);
  border-width: 3px 0;
  border-radius: 50%;
  content: "";
  transform: rotate(-18deg);
}

h1 {
  font-size: clamp(44px, 5.8vw, 80px);
  line-height: 0.98;
}

.lead {
  margin-top: 13px;
  color: var(--muted);
  font-size: clamp(15px, 1.5vw, 19px);
  font-weight: 800;
  line-height: 1.65;
}

.lead code {
  color: var(--coral-dark);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.speed-switch,
.code-switch {
  position: relative;
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgb(255 253 248 / 68%);
}

.speed-switch button,
.code-switch button {
  position: relative;
  z-index: 1;
  min-width: 58px;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 900;
}

.speed-switch button[aria-pressed="true"],
.code-switch button[aria-pressed="true"] {
  color: var(--ink);
  background: white;
  box-shadow: 0 4px 14px rgb(24 32 30 / 10%);
}

@supports (anchor-name: --selected-option) {
  .speed-switch::before,
  .code-switch::before {
    position: absolute;
    z-index: 0;
    top: anchor(top);
    left: anchor(left);
    width: anchor-size(width);
    height: anchor-size(height);
    border-radius: 9px;
    background: white;
    box-shadow: 0 4px 14px rgb(24 32 30 / 10%);
    content: "";
    pointer-events: none;
    transition:
      top 260ms cubic-bezier(0.22, 1, 0.36, 1),
      left 260ms cubic-bezier(0.22, 1, 0.36, 1),
      width 260ms cubic-bezier(0.22, 1, 0.36, 1),
      height 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .speed-switch button[aria-pressed="true"] {
    anchor-name: --speed-selected;
  }

  .speed-switch::before {
    position-anchor: --speed-selected;
  }

  .code-switch button[aria-pressed="true"] {
    anchor-name: --code-selected;
  }

  .code-switch::before {
    position-anchor: --code-selected;
  }

  .speed-switch button[aria-pressed="true"],
  .code-switch button[aria-pressed="true"] {
    background: transparent;
    box-shadow: none;
  }
}

.replay-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 13px;
  color: white;
  background: var(--ink);
  font-size: 11px;
  font-weight: 900;
  transition:
    background-color 160ms ease,
    transform 160ms ease;
}

.replay-button span {
  font-size: 18px;
}

.replay-button:hover {
  background: var(--coral-dark);
  transform: translateY(-2px);
}

.comparison-panel,
.roles-panel,
.code-panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgb(255 253 248 / 91%);
  box-shadow: var(--shadow);
}

.comparison-panel {
  padding: 22px;
}

.section-head,
.section-head > div {
  display: flex;
  align-items: center;
}

.section-head {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-head > div {
  gap: 12px;
}

.section-number {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: white;
  background: var(--coral);
  font-size: 11px;
  font-weight: 900;
}

.section-number--blue {
  background: var(--blue);
}

.section-head p,
.code-head > div > p {
  color: var(--coral-dark);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.section-head h2,
.code-head h2 {
  margin-top: 2px;
  font-size: 21px;
  line-height: 1.2;
}

.spring-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--blue-dark) !important;
  background: var(--blue-soft);
  letter-spacing: 0.08em !important;
}

.spring-label i {
  width: 23px;
  height: 8px;
  border: solid var(--blue);
  border-width: 2px 0;
  border-radius: 50%;
  transform: rotate(-10deg);
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.motion-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 19px;
  overflow: hidden;
}

.motion-card--rigid {
  background: #f0f2ef;
}

.motion-card--alive {
  border-color: rgb(240 111 82 / 30%);
  background: var(--coral-soft);
}

.motion-card > header,
.motion-card > footer,
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.motion-card > header span,
.motion-card > footer > span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.motion-card--alive > header span,
.motion-card--alive > footer > span {
  color: var(--coral-dark);
}

.motion-card h3 {
  margin-top: 3px;
  font-size: 18px;
}

.motion-card > header > code {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgb(255 255 255 / 58%);
  font-size: 9px;
  font-weight: 800;
}

.motion-track {
  position: relative;
  height: 190px;
  margin: 14px 0;
  border: 1px solid rgb(24 32 30 / 10%);
  border-radius: 15px;
  background:
    linear-gradient(rgb(24 32 30 / 5%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(24 32 30 / 5%) 1px, transparent 1px),
    rgb(255 255 255 / 66%);
  background-size: 22px 22px;
  overflow: hidden;
}

.motion-track::after {
  position: absolute;
  top: 50%;
  right: 24px;
  left: 24px;
  height: 2px;
  border-radius: 999px;
  background: rgb(24 32 30 / 10%);
  content: "";
}

.target-line {
  position: absolute;
  z-index: 0;
  top: 22px;
  right: 24px;
  bottom: 28px;
  border-left: 2px dashed rgb(24 32 30 / 18%);
}

.track-label {
  position: absolute;
  z-index: 2;
  bottom: 10px;
  color: var(--muted);
  font-size: 7px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.track-label--start {
  left: 24px;
}

.track-label--target {
  right: 24px;
}

.runner {
  --distance: 360px;
  position: absolute;
  z-index: 1;
  top: 48%;
  left: 24px;
  width: 76px;
  height: 76px;
  translate: 0 -50%;
  will-change: translate;
}

.motion-shape {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: #b9c0bc;
  box-shadow: 8px 10px 0 rgb(24 32 30 / 13%);
  transform-origin: center;
  will-change: scale, border-radius;
}

.runner--alive .motion-shape {
  color: white;
  background: var(--coral);
  transform-origin: right center;
}

.motion-shape span {
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.runner.is-playing {
  animation: move var(--duration, 1100ms) var(--travel-ease) both;
}

.runner--alive.is-playing .motion-shape {
  animation: squash-stretch var(--duration, 1100ms) linear both;
}

@keyframes move {
  0% {
    translate: 0 -50%;
  }

  68%,
  100% {
    translate: var(--distance) -50%;
  }
}

@keyframes squash-stretch {
  0% {
    scale: 1;
    border-radius: 50%;
  }

  20% {
    scale: 1.03 0.97;
    border-radius: 52% 48% 52% 48% / 48% 52% 48% 52%;
  }

  42% {
    scale: 1.07 0.93;
    border-radius: 53% 47% 53% 47% / 47% 53% 47% 53%;
  }

  60% {
    scale: 1.11 0.89;
    border-radius: 54% 46% 54% 46% / 46% 54% 46% 54%;
  }

  67.9% {
    scale: 1.14 0.86;
    border-radius: 55% 45% 55% 45% / 45% 55% 45% 55%;
  }

  68% {
    scale: 0.76 1.24;
    border-radius: 62% 10% 10% 62% / 50% 14% 14% 50%;
  }

  74% {
    scale: 0.76 1.24;
    border-radius: 62% 10% 10% 62% / 50% 14% 14% 50%;
  }

  84% {
    scale: 1.07 0.95;
    border-radius: 58% 8% 8% 58% / 50% 16% 16% 50%;
  }

  100% {
    scale: 1;
    border-radius: 50%;
  }
}

.motion-card > footer {
  align-items: flex-start;
}

.motion-card > footer p {
  max-width: 310px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.55;
  text-align: right;
}

.phase-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.phase-strip article {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 4px 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.phase-strip article > span {
  color: var(--coral-dark);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.phase-strip code {
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
}

.phase-shape {
  display: block;
  grid-row: 1 / 3;
  grid-column: 2;
  justify-self: end;
  width: 42px;
  height: 42px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
}

.phase-shape--arrival {
  scale: 0.76 1.24;
  border-radius: 62% 10% 10% 62% / 50% 14% 14% 50%;
  transform-origin: right center;
}

.phase-shape--rebound {
  scale: 1.07 0.95;
  border-radius: 58% 8% 8% 58% / 50% 16% 16% 50%;
  transform-origin: right center;
}

.phase-shape--travel {
  scale: 1.11 0.89;
  border-radius: 54% 46% 54% 46% / 46% 54% 46% 54%;
}

.details-grid {
  display: grid;
  grid-template-columns: 0.86fr 1.14fr;
  gap: 16px;
  margin-top: 16px;
}

.roles-panel,
.code-panel {
  min-width: 0;
  padding: 20px;
}

.section-head--compact {
  margin-bottom: 15px;
}

.role-list {
  display: grid;
  gap: 9px;
}

.role-list article {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
}

.role-list article > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  color: white;
  background: var(--blue);
  font-size: 8px;
  font-weight: 900;
}

.role-list code {
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 900;
}

.role-list p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.role-icon {
  position: relative;
  display: block;
  justify-self: end;
  width: 65px;
  height: 34px;
  border-radius: 10px;
  background: var(--blue-soft);
  overflow: hidden;
}

.role-icon--move::before {
  position: absolute;
  top: 14px;
  right: 11px;
  left: 11px;
  height: 3px;
  border-radius: 99px;
  background: var(--blue);
  content: "";
}

.role-icon--move::after {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  border: solid var(--blue);
  border-width: 3px 3px 0 0;
  content: "";
  transform: rotate(45deg);
}

.role-icon--scale::before {
  position: absolute;
  inset: 8px 18px;
  border: 3px solid var(--blue);
  border-radius: 50%;
  content: "";
  scale: 1.35 0.72;
}

.role-icon--radius::before {
  position: absolute;
  inset: 7px 18px;
  border: 3px solid var(--blue);
  border-radius: 9px 16px 7px 14px;
  content: "";
}

.roles-note {
  margin-top: 12px;
  padding: 12px 13px;
  border-radius: 12px;
  color: #645c4f;
  background: #f4ead2;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.65;
}

.code-panel {
  color: white;
  background: #111714;
}

.code-head {
  align-items: flex-end;
}

.code-head > div > p {
  color: #ffad9a;
}

.code-head h2 {
  color: white;
}

.code-head button {
  min-height: 39px;
  padding: 0 13px;
  border: 1px solid var(--coral);
  border-radius: 10px;
  color: white;
  background: var(--coral);
  font-size: 9px;
  font-weight: 900;
}

.code-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 16px;
  border-color: rgb(255 255 255 / 12%);
  background: rgb(255 255 255 / 7%);
}

.code-switch button {
  color: rgb(255 255 255 / 54%);
}

.code-switch button[aria-pressed="true"] {
  color: var(--ink);
}

.code-panel pre {
  min-height: 255px;
  max-height: 355px;
  margin-top: 12px;
  padding: 18px;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 13px;
  color: #e9f3ed;
  background: #0a0e0c;
  overflow: auto;
  font-size: clamp(10px, 1vw, 12px);
  line-height: 1.65;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-panel > footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  padding-top: 10px;
  color: rgb(255 255 255 / 50%);
  font-size: 9px;
  font-weight: 800;
}

.copy-status {
  color: #8ee0c5;
}

.page-note {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 15px;
  padding: 14px 16px;
  border: 1px solid rgb(240 111 82 / 23%);
  border-radius: 15px;
  color: #665d53;
  background: var(--coral-soft);
  font-size: 10px;
  font-weight: 800;
}

.page-note strong {
  color: var(--coral-dark);
  font-size: 9px;
  letter-spacing: 0.11em;
}

.page-note p {
  flex: 1;
}

.page-note span {
  color: var(--ink);
  white-space: nowrap;
}

button:focus-visible {
  outline: 3px solid rgb(57 120 242 / 36%);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .page {
    width: min(760px, calc(100% - 32px));
    padding-top: 24px;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .comparison-grid,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .phase-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .page {
    width: min(100% - 22px, 520px);
    padding-top: 17px;
  }

  h1 {
    font-size: clamp(38px, 12vw, 56px);
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .speed-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .replay-button {
    min-height: 46px;
  }

  .comparison-panel,
  .roles-panel,
  .code-panel {
    padding: 13px;
    border-radius: 20px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .spring-label {
    align-self: flex-start;
  }

  .motion-card {
    padding: 12px;
  }

  .motion-card > header,
  .motion-card > footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .motion-card > footer p {
    text-align: left;
  }

  .motion-track {
    height: 165px;
  }

  .runner,
  .motion-shape {
    width: 64px;
    height: 64px;
  }

  .phase-strip {
    grid-template-columns: 1fr;
  }

  .code-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .code-head button {
    width: 100%;
  }

  .code-switch button {
    min-width: 0;
    padding: 0 6px;
  }

  .page-note {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .runner.is-playing,
  .runner--alive.is-playing .motion-shape {
    animation-duration: 0.01ms !important;
  }
}
