// ═══ UI PRIMITIVES — Ashfall & Gilt ═══
const {useState,useEffect,useRef,useCallback,useMemo,useReducer}=React;

// ── Inline SVG icons (inherit currentColor through every state) ──
const ICON_PATHS={
  sword:"M14.5 3.5 20.5 3.5 20.5 9.5 9.5 20.5 3.5 14.5ZM5 19 3 21M7.5 16.5 10 19",
  shield:"M12 3 20 6v6c0 4.4-3.4 8.2-8 9-4.6-.8-8-4.6-8-9V6Z",
  heart:"M12 20.3C7 16.9 3.5 13.9 3.5 10.2A4.2 4.2 0 0 1 12 8a4.2 4.2 0 0 1 8.5 2.2c0 3.7-3.5 6.7-8.5 10.1Z",
  coin:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM12 17.5a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11ZM12 3v2M12 19v2",
  scroll:"M7 4h11a2 2 0 0 1 2 2v1H9V6a2 2 0 0 0-2-2Zm0 0a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7M9 11h8M9 15h5",
  crate:"M3 8h18v12H3ZM3 8l2-4h14l2 4M9 8v12M15 8v12M3 14h18",
  target:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM12 1v4M12 19v4M1 12h4M19 12h4",
  move:"M12 3v18M3 12h18M12 3 9 6M12 3l3 3M12 21l-3-3M12 21l3-3M3 12l3-3M3 12l3 3M21 12l-3-3M21 12l-3 3",
  range:"M4 20 20 4M20 4h-6M20 4v6M4 20h6M4 20v-6",
  gear:"M12 15.2a3.2 3.2 0 1 0 0-6.4 3.2 3.2 0 0 0 0 6.4Z M19.4 15a1.6 1.6 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.6 1.6 0 0 0-1.8-.3 1.6 1.6 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.6 1.6 0 0 0-1-1.5 1.6 1.6 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.6 1.6 0 0 0 .3-1.8 1.6 1.6 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.6 1.6 0 0 0 1.5-1 1.6 1.6 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.6 1.6 0 0 0 1.8.3H9a1.6 1.6 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.6 1.6 0 0 0 1 1.5 1.6 1.6 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.6 1.6 0 0 0-.3 1.8V9a1.6 1.6 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.6 1.6 0 0 0-1.5 1Z",
  close:"M6 6l12 12M18 6 6 18",
  chevL:"M15 5 8 12l7 7", chevR:"M9 5l7 7-7 7", chevD:"M5 9l7 7 7-7", chevU:"M5 15l7-7 7 7",
  dice:"M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2ZM8.5 8.5h.01M15.5 8.5h.01M12 12h.01M8.5 15.5h.01M15.5 15.5h.01",
  flame:"M12 22c3.9 0 7-3 7-6.8 0-4.5-4.2-6.6-4.2-10.4 0 0-2.6 1.3-2.6 4.6 0 2 .9 2.9.9 4.2a1.9 1.9 0 0 1-1.9 2c-1.3 0-2-1-2-2.4 0-.8.2-1.4.2-1.4S5 13.4 5 15.2C5 19 8.1 22 12 22Z",
  crown:"M4 18h16M4 18 3 7l5 4 4-6 4 6 5-4-1 11Z",
  flask:"M9 3h6M10 3v6L4.6 18a2 2 0 0 0 1.7 3h11.4a2 2 0 0 0 1.7-3L14 9V3M7.5 14h9",
  purse:"M6 8h12l2 12H4ZM9 8V6a3 3 0 0 1 6 0v2",
  skull:"M12 3a8 8 0 0 0-8 8c0 2.6 1.3 4.3 3 5.4V19a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2v-2.6c1.7-1.1 3-2.8 3-5.4a8 8 0 0 0-8-8ZM9 12h.01M15 12h.01",
  plus:"M12 5v14M5 12h14", minus:"M5 12h14",
  eye:"M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7Z M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",
  menu:"M4 7h16M4 12h16M4 17h16",
  layers:"M12 3 2 8l10 5 10-5ZM2 14l10 5 10-5M2 11l10 5 10-5",
  info:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM12 11v5M12 7.5h.01",
  check:"M4 12.5 9.5 18 20 6",
  rotate:"M3 12a9 9 0 1 1 3 6.7M3 19v-5h5",
  book:"M4 4h7v16H6a2 2 0 0 1-2-2ZM20 4h-7v16h5a2 2 0 0 0 2-2ZM11 4h2v16h-2Z",
  swap:"M7 4 3 8l4 4M3 8h12a4 4 0 0 1 4 4M17 20l4-4-4-4M21 16H9a4 4 0 0 1-4-4",
  bolt:"M13 2 4 14h7l-1 8 9-12h-7Z",
  users:"M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM2 21a7 7 0 0 1 14 0M17 11a3 3 0 1 0 0-6M18.5 21a6.5 6.5 0 0 0-2-4.7"
};
function Icon({n,size=20,style,fill}){
  const d=ICON_PATHS[n];if(!d)return null;
  return(<svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor"
    strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"
    style={{flex:"none",display:"block",...style}}>
    {d.split("M").filter(Boolean).map((seg,i)=><path key={i} d={"M"+seg} fill={fill||"none"}/>)}
  </svg>);
}

// ── Buttons ──
function Btn({children,onClick,variant,size,disabled,icon,style,hero,title,full}){
  const cls=["btn"];
  if(variant==="ghost")cls.push("btn--ghost");
  if(size==="sm")cls.push("btn--sm");
  if(hero)cls.push("btn--hero");
  return(<button className={cls.join(" ")} onClick={onClick} disabled={disabled} title={title}
    style={{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"var(--s-2)",width:full?"100%":undefined,...style}}>
    {icon&&<Icon n={icon} size={size==="sm"?15:17}/>}
    <span>{children}</span>
  </button>);
}
function IconBtn({icon,onClick,title,active,size=20,style,disabled,badge}){
  return(<button onClick={onClick} title={title} disabled={disabled} aria-label={title}
    style={{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",
      minWidth:44,minHeight:44,padding:0,cursor:disabled?"default":"pointer",
      // A cut board like the buttons. An outline on its own vanished against
      // the map — the icons need something solid behind them.
      backgroundColor:active?"#5A3315":"#191413",
      backgroundImage:'linear-gradient(rgba(10,8,6,.40),rgba(10,8,6,.40)),url("brand/burnt.jpg")',
      backgroundSize:"auto,cover",
      backgroundPosition:"center,center",
      border:"none",
      boxShadow:active
        ?"0 0 0 2px #E07A22,0 0 0 3px #190D06,inset 0 1px 0 rgba(255,220,170,.4),0 2px 0 #2A1408"
        :"0 0 0 2px #8A4A18,0 0 0 3px #190D06,inset 0 1px 0 rgba(255,208,150,.26),0 2px 0 #2A1408",
      borderRadius:6,
      color:active?"#FFDCA8":"#E8CFA6",
      textShadow:"0 1px 3px rgba(0,0,0,.9)",
      opacity:disabled?.35:1,
      transition:"color var(--d-hover) var(--ease-standard),border-color var(--d-hover) var(--ease-standard),background var(--d-hover)",...style}}>
    <Icon n={icon} size={size}/>
    {/* a count you can't miss — cards sitting unused in hand are invisible otherwise */}
    {badge>0&&<span style={{position:"absolute",top:-5,right:-5,minWidth:18,height:18,
      padding:"0 4px",borderRadius:9,display:"flex",alignItems:"center",justifyContent:"center",
      background:"var(--gold-500,#C9A227)",color:"#1A1206",fontSize:11,fontWeight:800,
      lineHeight:1,fontVariantNumeric:"tabular-nums",
      boxShadow:"0 1px 5px rgba(0,0,0,.7)",pointerEvents:"none"}}>{badge}</span>}
  </button>);
}
function Seg({options,value,onChange,style}){
  return(<div className="seg" style={style} role="tablist">
    {options.map(o=>(
      <button key={o.v} role="tab" aria-selected={value===o.v} onClick={()=>onChange(o.v)}>{o.l}</button>
    ))}
  </div>);
}
function Switch({checked,onChange}){
  return(<div className="switch" role="switch" aria-checked={checked?"true":"false"} tabIndex={0}
    onClick={()=>onChange(!checked)} onKeyDown={e=>{if(e.key===" "||e.key==="Enter"){e.preventDefault();onChange(!checked)}}}>
    <div className="knob"/>
  </div>);
}
function Slider({value,min=0,max=100,step=1,onChange}){
  const pct=((value-min)/(max-min))*100;
  return(<div className="row gap-3" style={{width:"100%"}}>
    <input type="range" min={min} max={max} step={step} value={value}
      onChange={e=>onChange(Number(e.target.value))} style={{"--pct":pct+"%"}}/>
    <span className="t-sm num dim" style={{width:34,textAlign:"right"}}>{value}</span>
  </div>);
}
function Rule({ornate}){
  if(!ornate)return <div className="hair" style={{margin:"var(--s-3) 0"}}/>;
  return(<div className="rule">
    <svg width="30" height="10" viewBox="0 0 30 10" aria-hidden="true">
      <path d="M15 0.5 L19 5 L15 9.5 L11 5 Z" fill="currentColor"/>
      <path d="M11 5 L8 5 M22 5 L19 5" stroke="currentColor" strokeWidth="1"/>
      <circle cx="6.5" cy="5" r="1.1" fill="currentColor" opacity=".7"/>
      <circle cx="23.5" cy="5" r="1.1" fill="currentColor" opacity=".7"/>
    </svg>
  </div>);
}

// ── Modal shell ──
function Modal({children,onClose,wide,pad=true}){
  useEffect(()=>{
    const onKey=e=>{if(e.key==="Escape")onClose&&onClose()};
    window.addEventListener("keydown",onKey);return()=>window.removeEventListener("keydown",onKey);
  },[onClose]);
  return(<div onClick={onClose} className="anim-fade" style={{position:"fixed",inset:0,zIndex:400,
    background:"rgba(6,5,4,.78)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",
    display:"flex",alignItems:"center",justifyContent:"center",padding:"var(--s-4)",
    paddingTop:"calc(var(--s-4) + var(--sa-t))",paddingBottom:"calc(var(--s-4) + var(--sa-b))"}}>
    <div className="panel anim-rise" onClick={e=>e.stopPropagation()}
      style={{maxWidth:wide?860:460,width:"100%",maxHeight:"100%",overflow:"auto",
        padding:pad?"var(--s-5)":0,display:"flex",flexDirection:"column"}}>
      {children}
    </div>
  </div>);
}

// ── Card art viewer ──
// The card itself, in 3D (js/cards3d.jsx): drag it any way to turn it over,
// or use the Specials / Front button.
function CardViewer({view,onClose,onFlip}){
  const[vw,setVw]=useState({w:window.innerWidth,h:window.innerHeight});
  const[diploSide,setDiploSide]=useState("front");
  useEffect(()=>{
    const on=()=>setVw({w:window.innerWidth,h:window.innerHeight});
    window.addEventListener("resize",on);return()=>window.removeEventListener("resize",on);
  },[]);
  useEffect(()=>{setDiploSide("front")},[view&&view.effect]);
  if(!view)return null;
  const isChar=view.kind==="char";
  const front=isChar?charCardURL(view.id,"front"):diploCardURL(view.effect);
  if(!front)return null;
  const back=isChar?charCardURL(view.id,"back"):DIPLO_BACK;
  const ratio=isChar?7/4:5/7;
  const width=Math.min(vw.w*.94,1100,vw.h*.74*ratio);
  const side=isChar?view.side:diploSide;
  const name=isChar?(C_BY_ID[view.id]||{}).name:view.name;
  return(<div onClick={onClose} className="anim-fade" style={{position:"fixed",inset:0,zIndex:500,
    background:"rgba(6,5,4,.9)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",
    display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"var(--s-4)",
    padding:"var(--s-4)",cursor:"zoom-out"}}>
    <div className="anim-rise">
      <Card3D key={isChar?view.id:view.effect} front={front} back={back} ratio={ratio} width={width}
        side={side} label={name} onSide={s=>{if(isChar){if(s!==view.side)onFlip()}else setDiploSide(s)}}/>
    </div>
    <div className="row gap-3" onClick={e=>e.stopPropagation()}>
      {isChar&&<Btn size="sm" icon="swap" onClick={onFlip}>{view.side==="front"?"Specials":"Front"}</Btn>}
      <Btn size="sm" variant="ghost" icon="close" onClick={onClose}>Close</Btn>
    </div>
    <div className="t-micro faint" style={{marginTop:"calc(var(--s-2) * -1)"}}>Drag the card to turn it over</div>
  </div>);
}

// ── Faction chip / stat display ──
function StatChip({icon,value,label,tone}){
  return(<div className="row gap-1" title={label} style={{color:tone||"var(--parch-400)"}}>
    <Icon n={icon} size={13}/><span className="t-micro num" style={{color:"var(--parch-200)"}}>{value}</span>
  </div>);
}
function StatBlock({c,compact}){
  const s=c.s||c.stats;
  return(<div className="row" style={{gap:compact?"var(--s-2)":"var(--s-3)",flexWrap:"wrap"}}>
    <StatChip icon="move" value={s.move} label="Move"/>
    <StatChip icon="range" value={s.range} label="Range"/>
    <StatChip icon="sword" value={s.attack} label="Attack"/>
    <StatChip icon="shield" value={s.defense} label="Defense"/>
    <StatChip icon="heart" value={s.life} label="Life"/>
    <StatChip icon="coin" value={(s.coin||s.coinRoll||[]).join(",")} label="Coin roll"/>
  </div>);
}
const TYPE_LABEL={Hero:"Hero",UniqueUnit:"Unique Unit",Group:"Group"};
function TypeBadge({c}){
  const col=c.type==="Hero"?"var(--gold-500)":c.type==="Group"?"var(--verdant-edge)":"var(--azure-edge)";
  return(<span className="t-micro" style={{color:col,border:"1px solid "+col,borderRadius:"var(--r-1)",
    padding:"1px 5px",letterSpacing:".08em",textTransform:"uppercase",whiteSpace:"nowrap"}}>
    {TYPE_LABEL[c.type]}{c.count>1?" ×"+c.count:""}
  </span>);
}

// ── Character roster tile (draft screens) ──
function CharTile({c,disabled,onPick,onInspect,selected}){
  const fc=FC[c.faction];
  return(<div style={{position:"relative",opacity:disabled?.3:1,
      transition:"opacity var(--d-state),transform var(--d-hover) var(--ease-standard)"}}>
    <button disabled={disabled} onClick={onPick}
      style={{display:"flex",alignItems:"center",gap:"var(--s-2)",width:"100%",minHeight:56,
        padding:"var(--s-2)",paddingRight:38,textAlign:"left",cursor:disabled?"default":"pointer",
        background:selected?"var(--leak-2)":"var(--leak-1)",
        border:"1px solid "+(selected?fc.p:"var(--ink-500)"),borderRadius:"var(--r-2)"}}>
      <img src={portraitURL(c)} alt="" loading="lazy"
        style={{width:34,height:44,objectFit:"cover",objectPosition:"top center",
          borderRadius:"var(--r-1)",border:"1px solid var(--ink-600)",flex:"none"}}/>
      <div className="grow col" style={{gap:2}}>
        <div className="row gap-2" style={{justifyContent:"space-between"}}>
          <span className="t-sm" style={{fontWeight:600,color:"var(--parch-100)",lineHeight:1.2}}>{c.name}</span>
          <span className="t-micro num" style={{color:fc.l,flex:"none"}}>SL{c.sl}</span>
        </div>
        <div className="row gap-2" style={{flexWrap:"wrap"}}>
          <TypeBadge c={c}/>
          <span className="t-micro num dim">
            <Icon n="sword" size={11} style={{display:"inline",verticalAlign:"-1px"}}/> {c.s.attack}
            {" · "}<Icon n="shield" size={11} style={{display:"inline",verticalAlign:"-1px"}}/> {c.s.defense}
            {" · "}<Icon n="heart" size={11} style={{display:"inline",verticalAlign:"-1px"}}/> {c.s.life}
          </span>
        </div>
      </div>
    </button>
    <button onClick={onInspect} title="View card" aria-label={"View "+c.name+" card"}
      style={{position:"absolute",right:2,top:"50%",transform:"translateY(-50%)",
        width:32,height:44,display:"flex",alignItems:"center",justifyContent:"center",
        background:"transparent",border:0,color:"var(--parch-600)",cursor:"pointer"}}>
      <Icon n="eye" size={16}/>
    </button>
  </div>);
}

// ── Bottom sheet (mobile) ──
function Sheet({children,onClose,title,maxH="62vh"}){
  return(<div style={{position:"absolute",left:0,right:0,bottom:0,zIndex:120,
      paddingLeft:"var(--sa-l)",paddingRight:"var(--sa-r)"}} className="anim-sheet">
    <div className="glass" style={{borderRadius:"var(--r-2) var(--r-2) 0 0",borderBottom:0,
      maxHeight:maxH,display:"flex",flexDirection:"column",paddingBottom:"var(--sa-b)"}}>
      {title&&<div className="row" style={{justifyContent:"space-between",padding:"var(--s-3) var(--s-4)",
        borderBottom:"1px solid var(--leak-1)"}}>
        <span className="t-h3" style={{color:"var(--gold-300)"}}>{title}</span>
        <IconBtn icon="close" onClick={onClose} title="Close" size={16}
          style={{minWidth:36,minHeight:36,border:0}}/>
      </div>}
      <div className="scroll grow">{children}</div>
    </div>
  </div>);
}

// ── Rotate-to-landscape gate ──
function RotateGate(){
  return(<div className="col center grain vignette ember-bg" style={{position:"fixed",inset:0,zIndex:900,
    gap:"var(--s-5)",padding:"var(--s-6)",textAlign:"center"}}>
    <img src="brand/logo-sm.png" alt="Barnburners &amp; Noblemen"
      style={{width:"min(78vw,300px)",height:"auto",position:"relative",zIndex:3,
        filter:"drop-shadow(0 8px 24px rgba(0,0,0,.8))"}}/>
    <div style={{color:"var(--gold-500)",animation:"riseIn 500ms var(--ease-out-quint) both",position:"relative",zIndex:3}}>
      <Icon n="rotate" size={48}/>
    </div>
    <div className="t-h2 gilt-text" style={{position:"relative",zIndex:3}}>Rotate Your Device</div>
    <p className="t-sm dim" style={{maxWidth:300,position:"relative",zIndex:3}}>
      The battle is fought on a wide hex map. Turn your phone sideways to take the field.
    </p>
  </div>);
}

// ── Responsive helper ──
function useViewport(){
  const get=()=>({w:window.innerWidth,h:window.innerHeight});
  const[v,setV]=useState(get);
  useEffect(()=>{
    let raf=null;
    const on=()=>{cancelAnimationFrame(raf);raf=requestAnimationFrame(()=>setV(get()))};
    window.addEventListener("resize",on);
    window.addEventListener("orientationchange",on);
    return()=>{window.removeEventListener("resize",on);window.removeEventListener("orientationchange",on);cancelAnimationFrame(raf)};
  },[]);
  return{...v,
    compact:v.w<900,          // phone / small tablet: drawer UI
    tiny:v.w<560,
    portraitPhone:v.h>v.w&&Math.min(v.w,v.h)<820};
}

// ── Heart burst ───────────────────────────────────────────────────────────
// What a hit cost, over the figure that paid it. The life a character had
// floats up as hearts, then the ones the attack took are smashed off, one
// after another, so damage is something you watch happen rather than a number
// you read in the log.
//
// `n` is the life before the hit, `lost` how many went. It renders nothing at
// all for zero damage — a blocked attack has its own beat and does not need
// hearts drifting over it.
const HEART_D="M12 21s-7.5-4.9-9.6-9.3C.7 8.1 2.5 4.6 5.9 4c2-.3 3.9.7 4.9 2.3h2.4C14.2 4.7 16.1 3.7 18.1 4c3.4.6 5.2 4.1 3.5 7.7C19.5 16.1 12 21 12 21z";
function HeartBurst({n,lost,max,colour,x,y,onDone,life=2600}){
  const total=Math.max(0,Math.min(n||0,max||n||0));
  const gone=Math.max(0,Math.min(lost||0,total));
  useEffect(()=>{
    if(!gone)return;
    const t=setTimeout(()=>onDone&&onDone(),life);
    return()=>clearTimeout(t);
  },[gone,life]);
  if(!gone)return null;
  // The survivors sit on the left, the smashed ones on the right, so the row
  // empties the way a life bar does rather than gapping in the middle.
  const kept=total-gone;
  const cell=Math.min(26,Math.max(15,Math.round(190/Math.max(total,1))));
  const stagger=150;
  return(
    <div style={{position:"fixed",left:(x||0),top:(y||0),zIndex:58,pointerEvents:"none",
      transform:"translate(-50%,-50%)",
      animation:`heartRise 260ms var(--ease-out-quint) both, heartsOut 460ms ease-in ${life-460}ms both`}}>
      <div style={{display:"flex",gap:2,alignItems:"center",
        padding:"5px 8px",borderRadius:"var(--r-pill)",
        background:"rgba(12,8,6,.62)",backdropFilter:"blur(5px)",
        border:"1px solid rgba(201,162,39,.35)",
        boxShadow:"0 6px 22px -8px rgba(0,0,0,.9)"}}>
        {Array.from({length:total}).map((_,i)=>{
          const smashed=i>=kept;
          const delay=smashed?(i-kept)*stagger+200:0;
          return(
            <span key={i} style={{position:"relative",width:cell,height:cell,
              display:"inline-flex",alignItems:"center",justifyContent:"center"}}>
              <svg viewBox="0 0 24 24" width={cell} height={cell} aria-hidden="true"
                style={{display:"block",
                  animation:smashed
                    ?`heartSmash 760ms cubic-bezier(.3,.9,.3,1) ${delay}ms both`
                    :`heartHold 1700ms ease-in-out ${i*90}ms infinite`}}>
                <path d={HEART_D}
                  fill={smashed?"#E04B3A":(colour||"#C8402F")}
                  stroke="rgba(0,0,0,.55)" strokeWidth="1.1"/>
                <path d={HEART_D} fill="none" stroke="rgba(255,235,200,.45)" strokeWidth=".8"
                  transform="translate(0,-.6)"/>
              </svg>
              {smashed&&[0,1,2,3,4].map(k=>{
                const ang=(-120+k*52)*Math.PI/180;
                return(<i key={k} style={{position:"absolute",left:"50%",top:"50%",
                  width:Math.max(2,cell/7),height:Math.max(2,cell/7),borderRadius:1,
                  background:k%2?"#FFD9A0":"#E04B3A",
                  "--sx":Math.round(Math.cos(ang)*cell*1.25)+"px",
                  "--sy":Math.round(Math.sin(ang)*cell*1.25)+"px",
                  "--sr":(k*77)+"deg",
                  animation:`heartShard 720ms ease-out ${delay+90}ms both`}}/>);
              })}
            </span>
          );
        })}
      </div>
    </div>
  );
}
