# Archery target button

> Click the target and an arrow sticks exactly where you aimed; every end of three arrows adds up its score.

- Category: [Buttons](https://library.aimran.es/components/buttons)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-btn-archery
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A round archery target with gold, red, blue, black and white rings inside a straw-colored frame. Each click fires an arrow that lands where the pointer was, seen from behind with its fletching, and the target shakes on impact. The ring decides the points, three slots below fill up and the total is announced. A fourth shot clears the end. Fun for sports clubs, games and goal trackers.

The main color is the fletching and the secondary color is the gold center, so you can match team colors. With the keyboard, Enter or Space shoots close to the center with a little random spread, and reduced motion removes the arrow flight.

## Code

### HTML

```html
<div class="uvq01-arc"><button class="tg" type="button" aria-label="Shoot arrow"></button><span class="sc" aria-hidden="true"><b class="s">-</b><b class="s">-</b><b class="s">-</b><span class="tl">Total</span><b class="sum">0</b></span><span class="sr" role="status"></span></div>
```

### CSS

```css
.uvq01-arc {
  --c1: #ff3d7f;
  --c2: #f5c518;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq01-arc {
  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;
  display: inline-grid;
  justify-items: center;
  gap: 1.1em;
}

.uvq01-arc .tg {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: block;
  width: 8em;
  height: 8em;
  border-radius: 50%;
  cursor: crosshair;
  touch-action: manipulation;
  background: repeating-radial-gradient(circle closest-side,transparent 0 9.3%,rgba(0,0,0,.3) 9.3% 10%),radial-gradient(circle closest-side,var(--c2) 0 20%,#e8402e 20% 40%,#2d7fe0 40% 60%,#1e1e20 60% 80%,#f3f1ea 80% 100%,transparent 100%);
  box-shadow: 0 0 0 .22em #d1ad6e,0 0 0 .38em #9c7a43,0 14px 26px -12px rgba(0,0,0,.55);
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-arc .tg::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: .5em;
  height: .5em;
  margin: -.25em;
  background: linear-gradient(45deg,transparent 45%,rgba(0,0,0,.55) 45% 55%,transparent 55%),linear-gradient(-45deg,transparent 45%,rgba(0,0,0,.55) 45% 55%,transparent 55%);
}

.uvq01-arc .ar {
  position: absolute;
  width: 1.15em;
  height: 1.15em;
  margin: -.575em 0 0 -.575em;
  border-radius: 50%;
  background: radial-gradient(circle,#222 0 17%,#f4f4f4 17% 25%,transparent 26%),conic-gradient(from -9deg,var(--c1) 0 18deg,transparent 18deg 120deg,var(--c1) 120deg 138deg,transparent 138deg 240deg,color-mix(in srgb,var(--c1) 60%,#fff) 240deg 258deg,transparent 258deg);
  filter: drop-shadow(.22em .28em .06em rgba(0,0,0,.45));
  animation: uvq01-arc-in calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}

.uvq01-arc .sc {
  display: flex;
  align-items: center;
  gap: .4em;
  font: 700 .85em/1 ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
}

.uvq01-arc .s,.uvq01-arc .sum {
  min-width: 2em;
  padding: .4em .35em;
  border-radius: .45em;
  text-align: center;
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 8%,transparent);
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-arc .s.on {
  color: #1b1b1b;
  background: var(--c2);
}

.uvq01-arc .tl {
  margin-left: .5em;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .85em;
  color: color-mix(in srgb,var(--fg) 60%,transparent);
}

.uvq01-arc .sum {
  color: var(--bg);
  background: var(--fg);
}

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

.uvq01-arc .tg:hover {
  transform: scale(1.02);
}

.uvq01-arc.is-hit .tg {
  animation: uvq01-arc-sh calc(0.28s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-arc .tg:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
  outline-offset: calc(.38em + 3px);
}

@keyframes uvq01-arc-in {
  0% {
    opacity: 0;
    transform: scale(2.6);
  }
  55% {
    opacity: 1;
    transform: scale(.92) rotate(8deg);
  }
  75% {
    transform: scale(1.04) rotate(-5deg);
  }
  100% {
    transform: none;
  }
}

@keyframes uvq01-arc-sh {
  30% {
    translate: .06em .05em;
  }
  60% {
    translate: -.04em -.03em;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq01-arc,.uvq01-arc *,.uvq01-arc *::before,.uvq01-arc *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq01-arc").forEach(el => {
  const tg=el.querySelector(".tg"),ss=[...el.querySelectorAll(".s")],sum=el.querySelector(".sum"),tl=el.querySelector(".tl"),sr=el.querySelector(".sr");let n=0,tot=0;
const shoot=(x,y)=>{if(n>=3){tg.querySelectorAll(".ar").forEach(a=>a.remove());ss.forEach(s=>{s.textContent="-";s.classList.remove("on")});n=0;tot=0}
const r=Math.hypot(x-.5,y-.5)*2;const p=r>=1?0:10-Math.floor(r*10);
if(p){const a=document.createElement("i");a.className="ar";a.style.left=(x*100).toFixed(1)+"%";a.style.top=(y*100).toFixed(1)+"%";tg.appendChild(a)}
ss[n].textContent=String(p);ss[n].classList.add("on");n++;tot+=p;sum.textContent=String(tot);sr.textContent=p+" · "+tl.textContent+" "+tot;
el.classList.remove("is-hit");void el.offsetWidth;el.classList.add("is-hit")};
tg.addEventListener("click",e=>{if(e.detail===0){const a=Math.random()*Math.PI*2,d=Math.random()*.24;shoot(.5+Math.cos(a)*d,.5+Math.sin(a)*d);return}const r=tg.getBoundingClientRect();shoot((e.clientX-r.left)/r.width,(e.clientY-r.top)/r.height)})
});
```

### 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 = `
.uvq01-arc {
  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;
  display: inline-grid;
  justify-items: center;
  gap: 1.1em;
}

.uvq01-arc .tg {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: block;
  width: 8em;
  height: 8em;
  border-radius: 50%;
  cursor: crosshair;
  touch-action: manipulation;
  background: repeating-radial-gradient(circle closest-side,transparent 0 9.3%,rgba(0,0,0,.3) 9.3% 10%),radial-gradient(circle closest-side,var(--c2) 0 20%,#e8402e 20% 40%,#2d7fe0 40% 60%,#1e1e20 60% 80%,#f3f1ea 80% 100%,transparent 100%);
  box-shadow: 0 0 0 .22em #d1ad6e,0 0 0 .38em #9c7a43,0 14px 26px -12px rgba(0,0,0,.55);
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-arc .tg::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: .5em;
  height: .5em;
  margin: -.25em;
  background: linear-gradient(45deg,transparent 45%,rgba(0,0,0,.55) 45% 55%,transparent 55%),linear-gradient(-45deg,transparent 45%,rgba(0,0,0,.55) 45% 55%,transparent 55%);
}

.uvq01-arc .ar {
  position: absolute;
  width: 1.15em;
  height: 1.15em;
  margin: -.575em 0 0 -.575em;
  border-radius: 50%;
  background: radial-gradient(circle,#222 0 17%,#f4f4f4 17% 25%,transparent 26%),conic-gradient(from -9deg,var(--c1) 0 18deg,transparent 18deg 120deg,var(--c1) 120deg 138deg,transparent 138deg 240deg,color-mix(in srgb,var(--c1) 60%,#fff) 240deg 258deg,transparent 258deg);
  filter: drop-shadow(.22em .28em .06em rgba(0,0,0,.45));
  animation: uvq01-arc-in calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}

.uvq01-arc .sc {
  display: flex;
  align-items: center;
  gap: .4em;
  font: 700 .85em/1 ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
}

.uvq01-arc .s,.uvq01-arc .sum {
  min-width: 2em;
  padding: .4em .35em;
  border-radius: .45em;
  text-align: center;
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 8%,transparent);
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-arc .s.on {
  color: #1b1b1b;
  background: var(--c2);
}

.uvq01-arc .tl {
  margin-left: .5em;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .85em;
  color: color-mix(in srgb,var(--fg) 60%,transparent);
}

.uvq01-arc .sum {
  color: var(--bg);
  background: var(--fg);
}

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

.uvq01-arc .tg:hover {
  transform: scale(1.02);
}

.uvq01-arc.is-hit .tg {
  animation: uvq01-arc-sh calc(0.28s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-arc .tg:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
  outline-offset: calc(.38em + 3px);
}

@keyframes uvq01-arc-in {
  0% {
    opacity: 0;
    transform: scale(2.6);
  }
  55% {
    opacity: 1;
    transform: scale(.92) rotate(8deg);
  }
  75% {
    transform: scale(1.04) rotate(-5deg);
  }
  100% {
    transform: none;
  }
}

@keyframes uvq01-arc-sh {
  30% {
    translate: .06em .05em;
  }
  60% {
    translate: -.04em -.03em;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq01-arc,.uvq01-arc *,.uvq01-arc *::before,.uvq01-arc *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// 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 tg=el.querySelector(".tg"),ss=[...el.querySelectorAll(".s")],sum=el.querySelector(".sum"),tl=el.querySelector(".tl"),sr=el.querySelector(".sr");let n=0,tot=0;
const shoot=(x,y)=>{if(n>=3){tg.querySelectorAll(".ar").forEach(a=>a.remove());ss.forEach(s=>{s.textContent="-";s.classList.remove("on")});n=0;tot=0}
const r=Math.hypot(x-.5,y-.5)*2;const p=r>=1?0:10-Math.floor(r*10);
if(p){const a=document.createElement("i");a.className="ar";a.style.left=(x*100).toFixed(1)+"%";a.style.top=(y*100).toFixed(1)+"%";tg.appendChild(a)}
ss[n].textContent=String(p);ss[n].classList.add("on");n++;tot+=p;sum.textContent=String(tot);sr.textContent=p+" · "+tl.textContent+" "+tot;
el.classList.remove("is-hit");void el.offsetWidth;el.classList.add("is-hit")};
tg.addEventListener("click",e=>{if(e.detail===0){const a=Math.random()*Math.PI*2,d=Math.random()*.24;shoot(.5+Math.cos(a)*d,.5+Math.sin(a)*d);return}const r=tg.getBoundingClientRect();shoot((e.clientX-r.left)/r.width,(e.clientY-r.top)/r.height)})
}

export default function BtnArchery() {
  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": "#ff3d7f",
          "--c2": "#f5c518",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq01-arc"><button className="tg" type="button" aria-label="Shoot arrow"></button><span className="sc" aria-hidden="true"><b className="s">-</b><b className="s">-</b><b className="s">-</b><span className="tl">Total</span><b className="sum">0</b></span><span className="sr" role="status"></span></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 “Archery target button” block (Buttons) from AIMRAN Library to my project.

## What it is
Click the target and an arrow sticks exactly where you aimed; every end of three arrows adds up its score.

## Chosen settings
- Main color: #ff3d7f
- Secondary color: #f5c518
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Disparar flecha"

## 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 = `
.uvq01-arc {
  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;
  display: inline-grid;
  justify-items: center;
  gap: 1.1em;
}

.uvq01-arc .tg {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: block;
  width: 8em;
  height: 8em;
  border-radius: 50%;
  cursor: crosshair;
  touch-action: manipulation;
  background: repeating-radial-gradient(circle closest-side,transparent 0 9.3%,rgba(0,0,0,.3) 9.3% 10%),radial-gradient(circle closest-side,var(--c2) 0 20%,#e8402e 20% 40%,#2d7fe0 40% 60%,#1e1e20 60% 80%,#f3f1ea 80% 100%,transparent 100%);
  box-shadow: 0 0 0 .22em #d1ad6e,0 0 0 .38em #9c7a43,0 14px 26px -12px rgba(0,0,0,.55);
  transition: transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq01-arc .tg::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: .5em;
  height: .5em;
  margin: -.25em;
  background: linear-gradient(45deg,transparent 45%,rgba(0,0,0,.55) 45% 55%,transparent 55%),linear-gradient(-45deg,transparent 45%,rgba(0,0,0,.55) 45% 55%,transparent 55%);
}

.uvq01-arc .ar {
  position: absolute;
  width: 1.15em;
  height: 1.15em;
  margin: -.575em 0 0 -.575em;
  border-radius: 50%;
  background: radial-gradient(circle,#222 0 17%,#f4f4f4 17% 25%,transparent 26%),conic-gradient(from -9deg,var(--c1) 0 18deg,transparent 18deg 120deg,var(--c1) 120deg 138deg,transparent 138deg 240deg,color-mix(in srgb,var(--c1) 60%,#fff) 240deg 258deg,transparent 258deg);
  filter: drop-shadow(.22em .28em .06em rgba(0,0,0,.45));
  animation: uvq01-arc-in calc(0.45s / var(--k)) cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}

.uvq01-arc .sc {
  display: flex;
  align-items: center;
  gap: .4em;
  font: 700 .85em/1 ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
}

.uvq01-arc .s,.uvq01-arc .sum {
  min-width: 2em;
  padding: .4em .35em;
  border-radius: .45em;
  text-align: center;
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 8%,transparent);
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-arc .s.on {
  color: #1b1b1b;
  background: var(--c2);
}

.uvq01-arc .tl {
  margin-left: .5em;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .85em;
  color: color-mix(in srgb,var(--fg) 60%,transparent);
}

.uvq01-arc .sum {
  color: var(--bg);
  background: var(--fg);
}

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

.uvq01-arc .tg:hover {
  transform: scale(1.02);
}

.uvq01-arc.is-hit .tg {
  animation: uvq01-arc-sh calc(0.28s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq01-arc .tg:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
  outline-offset: calc(.38em + 3px);
}

@keyframes uvq01-arc-in {
  0% {
    opacity: 0;
    transform: scale(2.6);
  }
  55% {
    opacity: 1;
    transform: scale(.92) rotate(8deg);
  }
  75% {
    transform: scale(1.04) rotate(-5deg);
  }
  100% {
    transform: none;
  }
}

@keyframes uvq01-arc-sh {
  30% {
    translate: .06em .05em;
  }
  60% {
    translate: -.04em -.03em;
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq01-arc,.uvq01-arc *,.uvq01-arc *::before,.uvq01-arc *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// 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 tg=el.querySelector(".tg"),ss=[...el.querySelectorAll(".s")],sum=el.querySelector(".sum"),tl=el.querySelector(".tl"),sr=el.querySelector(".sr");let n=0,tot=0;
const shoot=(x,y)=>{if(n>=3){tg.querySelectorAll(".ar").forEach(a=>a.remove());ss.forEach(s=>{s.textContent="-";s.classList.remove("on")});n=0;tot=0}
const r=Math.hypot(x-.5,y-.5)*2;const p=r>=1?0:10-Math.floor(r*10);
if(p){const a=document.createElement("i");a.className="ar";a.style.left=(x*100).toFixed(1)+"%";a.style.top=(y*100).toFixed(1)+"%";tg.appendChild(a)}
ss[n].textContent=String(p);ss[n].classList.add("on");n++;tot+=p;sum.textContent=String(tot);sr.textContent=p+" · "+tl.textContent+" "+tot;
el.classList.remove("is-hit");void el.offsetWidth;el.classList.add("is-hit")};
tg.addEventListener("click",e=>{if(e.detail===0){const a=Math.random()*Math.PI*2,d=Math.random()*.24;shoot(.5+Math.cos(a)*d,.5+Math.sin(a)*d);return}const r=tg.getBoundingClientRect();shoot((e.clientX-r.left)/r.width,(e.clientY-r.top)/r.height)})
}

export default function BtnArchery() {
  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": "#ff3d7f",
          "--c2": "#f5c518",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq01-arc"><button className="tg" type="button" aria-label="Shoot arrow"></button><span className="sc" aria-hidden="true"><b className="s">-</b><b className="s">-</b><b className="s">-</b><span className="tl">Total</span><b className="sum">0</b></span><span className="sr" role="status"></span></div>
      </div>
    </>
  );
}
```

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