# Glass marble with inertia

> A marble on a cutting mat: drag and release to throw it, and the grid appears upside down inside the glass.

- Category: [Liquid Glass](https://library.aimran.es/components/liquid-glass)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-lg-marble
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A glass marble rolling on a green cutting mat with grid lines, a protractor arc and a ruler. Inside the ball the mat is mirrored and magnified, the way a real sphere refracts what is behind it, and a red cat’s-eye ribbon spins as it rolls. The shadow carries a bright caustic spot where light focuses through the glass.

Throw it with a flick, tap the mat to nudge it towards that point, or push it with the arrow keys. It bounces off the edges and slows with friction. Use it as a playful hero, a 404 toy or a physics demo.

## Code

### HTML

```html
<div class="uvq11-mar"><div class="mat" aria-hidden="true"><b style="left:5%">1</b><b style="left:10%">2</b><b style="left:15%">3</b><b style="left:20%">4</b><b style="left:25%">5</b><b style="left:30%">6</b><b style="left:35%">7</b><b style="left:40%">8</b><b style="left:45%">9</b><b style="left:50%">10</b><b style="left:55%">11</b><b style="left:60%">12</b><b style="left:65%">13</b><b style="left:70%">14</b><b style="left:75%">15</b><b style="left:80%">16</b><b style="left:85%">17</b><b style="left:90%">18</b><b style="left:95%">19</b></div><p class="hn">Drag and throw</p><i class="sh" aria-hidden="true"></i><button type="button" class="mb" aria-label="Glass marble: drag it or push it with the arrow keys"><span class="rf"><span class="cp"></span></span><span class="sw"></span><span class="gs"></span></button></div>
```

### CSS

```css
.uvq11-mar {
  --c1: #e63946;
  --c2: #2f7d5b;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq11-mar {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 20em;
  height: 14em;
  border-radius: 1.6em;
  overflow: hidden;
  color: #fff;
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
  --x: 60px;
  --y: 80px;
  --r: 0deg;
  --mt: linear-gradient(rgba(255,255,255,.55) 1px,transparent 1px) 0 0/5em 5em,linear-gradient(90deg,rgba(255,255,255,.55) 1px,transparent 1px) 0 0/5em 5em,linear-gradient(rgba(255,255,255,.2) 1px,transparent 1px) 0 0/1em 1em,linear-gradient(90deg,rgba(255,255,255,.2) 1px,transparent 1px) 0 0/1em 1em,radial-gradient(circle at 76% 70%,transparent 3.9em,rgba(255,236,150,.75) 3.9em 4em,transparent 4.05em),linear-gradient(35deg,transparent 49.6%,rgba(255,236,150,.6) 49.6% 50.4%,transparent 50.4%),var(--c2);
  background: var(--mt);
  touch-action: none;
}

.uvq11-mar .mat {
  position: absolute;
  inset: 0;
}

.uvq11-mar .mat b {
  position: absolute;
  top: .3em;
  font-size: .42em;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  transform: translateX(-50%);
  margin-left: 0;
}

.uvq11-mar .hn {
  position: absolute;
  left: 1em;
  bottom: .7em;
  margin: 0;
  font-size: .66em;
  font-weight: 700;
  letter-spacing: .04em;
  color: rgba(255,255,255,.8);
}

.uvq11-mar .sh {
  position: absolute;
  left: 0;
  top: 0;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(calc(var(--x) + .5em),calc(var(--y) + .65em)) scale(1.05,.92);
  background: radial-gradient(circle at 58% 58%,color-mix(in srgb,var(--c1) 35%,#fff) 0 10%,transparent 24%),radial-gradient(circle,rgba(0,20,10,.45) 30%,transparent 70%);
}

.uvq11-mar .mb {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  left: 0;
  top: 0;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  transform: translate(var(--x),var(--y));
}

.uvq11-mar .mb:active {
  cursor: grabbing;
}

.uvq11-mar .mb:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  outline-offset: 3px;
}

.uvq11-mar .rf {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  filter: saturate(1.3) brightness(1.12);
}

.uvq11-mar .cp {
  position: absolute;
  left: calc(-1 * var(--x));
  top: calc(-1 * var(--y));
  width: 20em;
  height: 14em;
  background: var(--mt);
  transform-origin: calc(var(--x) + 1.5em) calc(var(--y) + 1.5em);
  transform: scale(-1.7);
}

.uvq11-mar .sw {
  position: absolute;
  inset: .45em;
  border-radius: 50%;
  background: conic-gradient(from 0deg,transparent 0 18deg,var(--c1) 26deg 44deg,transparent 52deg 130deg,rgba(255,255,255,.9) 138deg 150deg,transparent 158deg 198deg,var(--c1) 206deg 224deg,transparent 232deg 310deg,#ffd166 318deg 330deg,transparent 338deg);
  -webkit-mask: radial-gradient(closest-side,#000 30%,transparent 95%);
  mask: radial-gradient(closest-side,#000 30%,transparent 95%);
  transform: rotate(var(--r)) scaleY(.75);
  opacity: .9;
}

.uvq11-mar .gs {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 27%,rgba(255,255,255,.98) 0 .16em,rgba(255,255,255,.35) .42em,transparent .9em),radial-gradient(circle,transparent 52%,rgba(0,40,25,.4) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45),inset -.25em -.35em .6em rgba(0,0,0,.28),inset .2em .25em .5em rgba(255,255,255,.3);
}
```

### JavaScript

```js
document.querySelectorAll(".uvq11-mar").forEach(el => {
  const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;const mb=el.querySelector(".mb"),W=el.offsetWidth,H=el.offsetHeight,D=mb.offsetWidth;let x=W*.3,y=H*.4,vx=0,vy=0,r=0,raf=0,last=0,dr=null,hist=[],moved=0;
const draw=()=>{el.style.setProperty("--x",x.toFixed(1)+"px");el.style.setProperty("--y",y.toFixed(1)+"px");el.style.setProperty("--r",r.toFixed(1)+"deg")};
const step=t=>{const f=Math.min(3,(t-(last||t))/16);last=t;if(!dr){x+=vx*f;y+=vy*f;r+=(vx+vy*.5)*f*360/(Math.PI*D);const k=Math.pow(.982,f);vx*=k;vy*=k;
if(x<0){x=0;vx=-vx*.7}if(x>W-D){x=W-D;vx=-vx*.7}if(y<0){y=0;vy=-vy*.7}if(y>H-D){y=H-D;vy=-vy*.7}}
draw();if(dr||Math.hypot(vx,vy)>.03)raf=requestAnimationFrame(step);else{raf=0;last=0}};
const go=()=>{if(!raf){last=0;raf=requestAnimationFrame(step)}};
const S=()=>el.getBoundingClientRect().width/W||1;
mb.addEventListener("pointerdown",e=>{e.stopPropagation();mb.setPointerCapture(e.pointerId);const s=S();dr={s:s,ox:e.clientX/s-x,oy:e.clientY/s-y};hist=[];moved=0;vx=vy=0;go()});
mb.addEventListener("pointermove",e=>{if(!dr)return;const nx=Math.max(0,Math.min(W-D,e.clientX/dr.s-dr.ox)),ny=Math.max(0,Math.min(H-D,e.clientY/dr.s-dr.oy));moved+=Math.abs(nx-x)+Math.abs(ny-y);r+=(nx-x+(ny-y)*.5)*360/(Math.PI*D);x=nx;y=ny;hist.push([performance.now(),x,y]);if(hist.length>6)hist.shift()});
const up=()=>{if(!dr)return;dr=null;if(hist.length>1){const a=hist[0],b=hist[hist.length-1],dt=Math.max(8,b[0]-a[0])/16;vx=Math.max(-40,Math.min(40,(b[1]-a[1])/dt));vy=Math.max(-40,Math.min(40,(b[2]-a[2])/dt))}go()};
mb.addEventListener("pointerup",up);mb.addEventListener("pointercancel",up);
el.addEventListener("pointerdown",e=>{if(e.target===mb||mb.contains(e.target))return;const r0=el.getBoundingClientRect(),s=S(),px=(e.clientX-r0.left)/s,py=(e.clientY-r0.top)/s,dx=px-(x+D/2),dy=py-(y+D/2),d=Math.hypot(dx,dy)||1;vx+=dx/d*7;vy+=dy/d*7;go()});
mb.addEventListener("click",()=>{if(moved>4){moved=0;return}if(!dr&&Math.hypot(vx,vy)<1){const a=Math.random()*Math.PI*2;vx=Math.cos(a)*9;vy=Math.sin(a)*9;go()}});
mb.addEventListener("keydown",e=>{const k={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!k)return;e.preventDefault();vx+=k[0]*3;vy+=k[1]*3;go()});
draw();const t0=rm?0:setTimeout(()=>{vx=7;vy=-2.6;go()},500);
return()=>{clearTimeout(t0);cancelAnimationFrame(raf)}
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq11-mar {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 20em;
  height: 14em;
  border-radius: 1.6em;
  overflow: hidden;
  color: #fff;
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
  --x: 60px;
  --y: 80px;
  --r: 0deg;
  --mt: linear-gradient(rgba(255,255,255,.55) 1px,transparent 1px) 0 0/5em 5em,linear-gradient(90deg,rgba(255,255,255,.55) 1px,transparent 1px) 0 0/5em 5em,linear-gradient(rgba(255,255,255,.2) 1px,transparent 1px) 0 0/1em 1em,linear-gradient(90deg,rgba(255,255,255,.2) 1px,transparent 1px) 0 0/1em 1em,radial-gradient(circle at 76% 70%,transparent 3.9em,rgba(255,236,150,.75) 3.9em 4em,transparent 4.05em),linear-gradient(35deg,transparent 49.6%,rgba(255,236,150,.6) 49.6% 50.4%,transparent 50.4%),var(--c2);
  background: var(--mt);
  touch-action: none;
}

.uvq11-mar .mat {
  position: absolute;
  inset: 0;
}

.uvq11-mar .mat b {
  position: absolute;
  top: .3em;
  font-size: .42em;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  transform: translateX(-50%);
  margin-left: 0;
}

.uvq11-mar .hn {
  position: absolute;
  left: 1em;
  bottom: .7em;
  margin: 0;
  font-size: .66em;
  font-weight: 700;
  letter-spacing: .04em;
  color: rgba(255,255,255,.8);
}

.uvq11-mar .sh {
  position: absolute;
  left: 0;
  top: 0;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(calc(var(--x) + .5em),calc(var(--y) + .65em)) scale(1.05,.92);
  background: radial-gradient(circle at 58% 58%,color-mix(in srgb,var(--c1) 35%,#fff) 0 10%,transparent 24%),radial-gradient(circle,rgba(0,20,10,.45) 30%,transparent 70%);
}

.uvq11-mar .mb {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  left: 0;
  top: 0;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  transform: translate(var(--x),var(--y));
}

.uvq11-mar .mb:active {
  cursor: grabbing;
}

.uvq11-mar .mb:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  outline-offset: 3px;
}

.uvq11-mar .rf {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  filter: saturate(1.3) brightness(1.12);
}

.uvq11-mar .cp {
  position: absolute;
  left: calc(-1 * var(--x));
  top: calc(-1 * var(--y));
  width: 20em;
  height: 14em;
  background: var(--mt);
  transform-origin: calc(var(--x) + 1.5em) calc(var(--y) + 1.5em);
  transform: scale(-1.7);
}

.uvq11-mar .sw {
  position: absolute;
  inset: .45em;
  border-radius: 50%;
  background: conic-gradient(from 0deg,transparent 0 18deg,var(--c1) 26deg 44deg,transparent 52deg 130deg,rgba(255,255,255,.9) 138deg 150deg,transparent 158deg 198deg,var(--c1) 206deg 224deg,transparent 232deg 310deg,#ffd166 318deg 330deg,transparent 338deg);
  -webkit-mask: radial-gradient(closest-side,#000 30%,transparent 95%);
  mask: radial-gradient(closest-side,#000 30%,transparent 95%);
  transform: rotate(var(--r)) scaleY(.75);
  opacity: .9;
}

.uvq11-mar .gs {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 27%,rgba(255,255,255,.98) 0 .16em,rgba(255,255,255,.35) .42em,transparent .9em),radial-gradient(circle,transparent 52%,rgba(0,40,25,.4) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45),inset -.25em -.35em .6em rgba(0,0,0,.28),inset .2em .25em .5em rgba(255,255,255,.3);
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;const mb=el.querySelector(".mb"),W=el.offsetWidth,H=el.offsetHeight,D=mb.offsetWidth;let x=W*.3,y=H*.4,vx=0,vy=0,r=0,raf=0,last=0,dr=null,hist=[],moved=0;
const draw=()=>{el.style.setProperty("--x",x.toFixed(1)+"px");el.style.setProperty("--y",y.toFixed(1)+"px");el.style.setProperty("--r",r.toFixed(1)+"deg")};
const step=t=>{const f=Math.min(3,(t-(last||t))/16);last=t;if(!dr){x+=vx*f;y+=vy*f;r+=(vx+vy*.5)*f*360/(Math.PI*D);const k=Math.pow(.982,f);vx*=k;vy*=k;
if(x<0){x=0;vx=-vx*.7}if(x>W-D){x=W-D;vx=-vx*.7}if(y<0){y=0;vy=-vy*.7}if(y>H-D){y=H-D;vy=-vy*.7}}
draw();if(dr||Math.hypot(vx,vy)>.03)raf=requestAnimationFrame(step);else{raf=0;last=0}};
const go=()=>{if(!raf){last=0;raf=requestAnimationFrame(step)}};
const S=()=>el.getBoundingClientRect().width/W||1;
mb.addEventListener("pointerdown",e=>{e.stopPropagation();mb.setPointerCapture(e.pointerId);const s=S();dr={s:s,ox:e.clientX/s-x,oy:e.clientY/s-y};hist=[];moved=0;vx=vy=0;go()});
mb.addEventListener("pointermove",e=>{if(!dr)return;const nx=Math.max(0,Math.min(W-D,e.clientX/dr.s-dr.ox)),ny=Math.max(0,Math.min(H-D,e.clientY/dr.s-dr.oy));moved+=Math.abs(nx-x)+Math.abs(ny-y);r+=(nx-x+(ny-y)*.5)*360/(Math.PI*D);x=nx;y=ny;hist.push([performance.now(),x,y]);if(hist.length>6)hist.shift()});
const up=()=>{if(!dr)return;dr=null;if(hist.length>1){const a=hist[0],b=hist[hist.length-1],dt=Math.max(8,b[0]-a[0])/16;vx=Math.max(-40,Math.min(40,(b[1]-a[1])/dt));vy=Math.max(-40,Math.min(40,(b[2]-a[2])/dt))}go()};
mb.addEventListener("pointerup",up);mb.addEventListener("pointercancel",up);
el.addEventListener("pointerdown",e=>{if(e.target===mb||mb.contains(e.target))return;const r0=el.getBoundingClientRect(),s=S(),px=(e.clientX-r0.left)/s,py=(e.clientY-r0.top)/s,dx=px-(x+D/2),dy=py-(y+D/2),d=Math.hypot(dx,dy)||1;vx+=dx/d*7;vy+=dy/d*7;go()});
mb.addEventListener("click",()=>{if(moved>4){moved=0;return}if(!dr&&Math.hypot(vx,vy)<1){const a=Math.random()*Math.PI*2;vx=Math.cos(a)*9;vy=Math.sin(a)*9;go()}});
mb.addEventListener("keydown",e=>{const k={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!k)return;e.preventDefault();vx+=k[0]*3;vy+=k[1]*3;go()});
draw();const t0=rm?0:setTimeout(()=>{vx=7;vy=-2.6;go()},500);
return()=>{clearTimeout(t0);cancelAnimationFrame(raf)}
}

export default function LgMarble() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#e63946",
          "--c2": "#2f7d5b",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq11-mar"><div className="mat" aria-hidden="true"><b style={{ left: "5%" }}>1</b><b style={{ left: "10%" }}>2</b><b style={{ left: "15%" }}>3</b><b style={{ left: "20%" }}>4</b><b style={{ left: "25%" }}>5</b><b style={{ left: "30%" }}>6</b><b style={{ left: "35%" }}>7</b><b style={{ left: "40%" }}>8</b><b style={{ left: "45%" }}>9</b><b style={{ left: "50%" }}>10</b><b style={{ left: "55%" }}>11</b><b style={{ left: "60%" }}>12</b><b style={{ left: "65%" }}>13</b><b style={{ left: "70%" }}>14</b><b style={{ left: "75%" }}>15</b><b style={{ left: "80%" }}>16</b><b style={{ left: "85%" }}>17</b><b style={{ left: "90%" }}>18</b><b style={{ left: "95%" }}>19</b></div><p className="hn">Drag and throw</p><i className="sh" aria-hidden="true"></i><button type="button" className="mb" aria-label="Glass marble: drag it or push it with the arrow keys"><span className="rf"><span className="cp"></span></span><span className="sw"></span><span className="gs"></span></button></div>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Glass marble with inertia” block (Liquid Glass) from AIMRAN Library to my project.

## What it is
A marble on a cutting mat: drag and release to throw it, and the grid appears upside down inside the glass.

## Chosen settings
- Main color: #e63946
- Secondary color: #2f7d5b
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq11-mar {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  width: 20em;
  height: 14em;
  border-radius: 1.6em;
  overflow: hidden;
  color: #fff;
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
  --x: 60px;
  --y: 80px;
  --r: 0deg;
  --mt: linear-gradient(rgba(255,255,255,.55) 1px,transparent 1px) 0 0/5em 5em,linear-gradient(90deg,rgba(255,255,255,.55) 1px,transparent 1px) 0 0/5em 5em,linear-gradient(rgba(255,255,255,.2) 1px,transparent 1px) 0 0/1em 1em,linear-gradient(90deg,rgba(255,255,255,.2) 1px,transparent 1px) 0 0/1em 1em,radial-gradient(circle at 76% 70%,transparent 3.9em,rgba(255,236,150,.75) 3.9em 4em,transparent 4.05em),linear-gradient(35deg,transparent 49.6%,rgba(255,236,150,.6) 49.6% 50.4%,transparent 50.4%),var(--c2);
  background: var(--mt);
  touch-action: none;
}

.uvq11-mar .mat {
  position: absolute;
  inset: 0;
}

.uvq11-mar .mat b {
  position: absolute;
  top: .3em;
  font-size: .42em;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  transform: translateX(-50%);
  margin-left: 0;
}

.uvq11-mar .hn {
  position: absolute;
  left: 1em;
  bottom: .7em;
  margin: 0;
  font-size: .66em;
  font-weight: 700;
  letter-spacing: .04em;
  color: rgba(255,255,255,.8);
}

.uvq11-mar .sh {
  position: absolute;
  left: 0;
  top: 0;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(calc(var(--x) + .5em),calc(var(--y) + .65em)) scale(1.05,.92);
  background: radial-gradient(circle at 58% 58%,color-mix(in srgb,var(--c1) 35%,#fff) 0 10%,transparent 24%),radial-gradient(circle,rgba(0,20,10,.45) 30%,transparent 70%);
}

.uvq11-mar .mb {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  left: 0;
  top: 0;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  transform: translate(var(--x),var(--y));
}

.uvq11-mar .mb:active {
  cursor: grabbing;
}

.uvq11-mar .mb:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  outline-offset: 3px;
}

.uvq11-mar .rf {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  filter: saturate(1.3) brightness(1.12);
}

.uvq11-mar .cp {
  position: absolute;
  left: calc(-1 * var(--x));
  top: calc(-1 * var(--y));
  width: 20em;
  height: 14em;
  background: var(--mt);
  transform-origin: calc(var(--x) + 1.5em) calc(var(--y) + 1.5em);
  transform: scale(-1.7);
}

.uvq11-mar .sw {
  position: absolute;
  inset: .45em;
  border-radius: 50%;
  background: conic-gradient(from 0deg,transparent 0 18deg,var(--c1) 26deg 44deg,transparent 52deg 130deg,rgba(255,255,255,.9) 138deg 150deg,transparent 158deg 198deg,var(--c1) 206deg 224deg,transparent 232deg 310deg,#ffd166 318deg 330deg,transparent 338deg);
  -webkit-mask: radial-gradient(closest-side,#000 30%,transparent 95%);
  mask: radial-gradient(closest-side,#000 30%,transparent 95%);
  transform: rotate(var(--r)) scaleY(.75);
  opacity: .9;
}

.uvq11-mar .gs {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 27%,rgba(255,255,255,.98) 0 .16em,rgba(255,255,255,.35) .42em,transparent .9em),radial-gradient(circle,transparent 52%,rgba(0,40,25,.4) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45),inset -.25em -.35em .6em rgba(0,0,0,.28),inset .2em .25em .5em rgba(255,255,255,.3);
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;const mb=el.querySelector(".mb"),W=el.offsetWidth,H=el.offsetHeight,D=mb.offsetWidth;let x=W*.3,y=H*.4,vx=0,vy=0,r=0,raf=0,last=0,dr=null,hist=[],moved=0;
const draw=()=>{el.style.setProperty("--x",x.toFixed(1)+"px");el.style.setProperty("--y",y.toFixed(1)+"px");el.style.setProperty("--r",r.toFixed(1)+"deg")};
const step=t=>{const f=Math.min(3,(t-(last||t))/16);last=t;if(!dr){x+=vx*f;y+=vy*f;r+=(vx+vy*.5)*f*360/(Math.PI*D);const k=Math.pow(.982,f);vx*=k;vy*=k;
if(x<0){x=0;vx=-vx*.7}if(x>W-D){x=W-D;vx=-vx*.7}if(y<0){y=0;vy=-vy*.7}if(y>H-D){y=H-D;vy=-vy*.7}}
draw();if(dr||Math.hypot(vx,vy)>.03)raf=requestAnimationFrame(step);else{raf=0;last=0}};
const go=()=>{if(!raf){last=0;raf=requestAnimationFrame(step)}};
const S=()=>el.getBoundingClientRect().width/W||1;
mb.addEventListener("pointerdown",e=>{e.stopPropagation();mb.setPointerCapture(e.pointerId);const s=S();dr={s:s,ox:e.clientX/s-x,oy:e.clientY/s-y};hist=[];moved=0;vx=vy=0;go()});
mb.addEventListener("pointermove",e=>{if(!dr)return;const nx=Math.max(0,Math.min(W-D,e.clientX/dr.s-dr.ox)),ny=Math.max(0,Math.min(H-D,e.clientY/dr.s-dr.oy));moved+=Math.abs(nx-x)+Math.abs(ny-y);r+=(nx-x+(ny-y)*.5)*360/(Math.PI*D);x=nx;y=ny;hist.push([performance.now(),x,y]);if(hist.length>6)hist.shift()});
const up=()=>{if(!dr)return;dr=null;if(hist.length>1){const a=hist[0],b=hist[hist.length-1],dt=Math.max(8,b[0]-a[0])/16;vx=Math.max(-40,Math.min(40,(b[1]-a[1])/dt));vy=Math.max(-40,Math.min(40,(b[2]-a[2])/dt))}go()};
mb.addEventListener("pointerup",up);mb.addEventListener("pointercancel",up);
el.addEventListener("pointerdown",e=>{if(e.target===mb||mb.contains(e.target))return;const r0=el.getBoundingClientRect(),s=S(),px=(e.clientX-r0.left)/s,py=(e.clientY-r0.top)/s,dx=px-(x+D/2),dy=py-(y+D/2),d=Math.hypot(dx,dy)||1;vx+=dx/d*7;vy+=dy/d*7;go()});
mb.addEventListener("click",()=>{if(moved>4){moved=0;return}if(!dr&&Math.hypot(vx,vy)<1){const a=Math.random()*Math.PI*2;vx=Math.cos(a)*9;vy=Math.sin(a)*9;go()}});
mb.addEventListener("keydown",e=>{const k={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[e.key];if(!k)return;e.preventDefault();vx+=k[0]*3;vy+=k[1]*3;go()});
draw();const t0=rm?0:setTimeout(()=>{vx=7;vy=-2.6;go()},500);
return()=>{clearTimeout(t0);cancelAnimationFrame(raf)}
}

export default function LgMarble() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#e63946",
          "--c2": "#2f7d5b",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq11-mar"><div className="mat" aria-hidden="true"><b style={{ left: "5%" }}>1</b><b style={{ left: "10%" }}>2</b><b style={{ left: "15%" }}>3</b><b style={{ left: "20%" }}>4</b><b style={{ left: "25%" }}>5</b><b style={{ left: "30%" }}>6</b><b style={{ left: "35%" }}>7</b><b style={{ left: "40%" }}>8</b><b style={{ left: "45%" }}>9</b><b style={{ left: "50%" }}>10</b><b style={{ left: "55%" }}>11</b><b style={{ left: "60%" }}>12</b><b style={{ left: "65%" }}>13</b><b style={{ left: "70%" }}>14</b><b style={{ left: "75%" }}>15</b><b style={{ left: "80%" }}>16</b><b style={{ left: "85%" }}>17</b><b style={{ left: "90%" }}>18</b><b style={{ left: "95%" }}>19</b></div><p className="hn">Drag and throw</p><i className="sh" aria-hidden="true"></i><button type="button" className="mb" aria-label="Glass marble: drag it or push it with the arrow keys"><span className="rf"><span className="cp"></span></span><span className="sw"></span><span className="gs"></span></button></div>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
