/* 3-patti round race (owner request, 2026-10-16). Every animation runs a set
   number of times and stops, and only moves or fades elements (see DESIGN.md,
   resting table). The screen stays up until Continue; the runners keep a
   small bounce where they stopped for about two minutes, then rest.
   Each lane carries its own timing from race.js: --start (the runner sets
   off), --run (how long they run), --arrive (they reach their new total) and
   --legs (strides); the card carries --headline. */
.race-overlay{position:fixed;inset:0;z-index:60;display:grid;place-items:center;padding:max(12px,env(safe-area-inset-top)) 12px max(12px,env(safe-area-inset-bottom));animation:race-in .28s ease-out both}
.race-overlay.leaving{animation:race-out .24s ease-in both}
.race-backdrop{position:absolute;inset:0;background:radial-gradient(circle at 50% 30%,#2f735aee,#0d2a20f7 70%)}
.race-card{position:relative;width:min(100%,760px);max-height:100%;overflow-x:hidden;overflow-y:auto;background:#fffdf6;border-radius:20px;padding:16px 16px 0;box-shadow:0 24px 60px #0006;color:#203a31;cursor:default}
.race-head{text-align:center;margin-bottom:10px}
.race-eyebrow{font-size:.7rem;letter-spacing:.16em;text-transform:uppercase;font-weight:750;color:#9a7433}
.race-head h2{font-size:clamp(1.5rem,5vw,2.3rem);margin:2px 0 0}
.race-sub{font-size:.88rem;color:#6a7366}
.race-field{position:relative;padding:18px 0 2px}
.race-lanes{list-style:none;margin:0;padding:0;display:grid;gap:4px;container-type:inline-size}
/* The start at 6% and the finish line (the points limit) at 88% of each
   track; the limit is named once above the first lane. */
.race-line{position:absolute;top:0;left:88%;transform:translateX(-50%);font-size:.76rem;font-weight:700;background:#203a31;color:#fff;padding:1px 6px;border-radius:8px;white-space:nowrap;pointer-events:none}
.race-track::before,.race-track::after{content:"";position:absolute;bottom:0;pointer-events:none}
.race-track::before{left:6%;top:10px;border-left:2px dashed #c8cfbf}
.race-track::after{left:88%;top:10px;width:8px;margin-left:-4px;background:repeating-conic-gradient(#203a31 0 25%,#fffdf6 0 50%) 0 0/8px 8px;opacity:.85}
.race-lane{position:relative;padding:2px 0;isolation:isolate}
.race-lane-head{display:flex;align-items:baseline;gap:6px;font-size:.86rem;line-height:1.2;padding:0 2px;min-width:0}
.race-name{font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:38%}
.race-name small{font-weight:500;color:#6a7366}
.race-score{font-variant-numeric:tabular-nums;font-weight:700}
.race-score small{font-weight:600;color:#9a7433}
.race-caption{margin-left:auto;font-style:italic;color:#4d5a50;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;opacity:0;animation:race-fade .4s ease-out var(--arrive) both}
.race-track{position:relative;height:54px;border-bottom:2px solid #e3e6da;background:linear-gradient(#0000 70%,#eef1e6 70%)}
.race-lane.you .race-track{background:linear-gradient(#0000 70%,#f6e9c8 70%)}
.race-runner{position:absolute;left:0;bottom:2px;width:40px;height:48px;transform:translateX(calc(6cqw + var(--to) * 82cqw - 50%));animation:race-run var(--run) cubic-bezier(.35,.08,.3,1) var(--start) both}
.race-hopper{position:absolute;inset:0}
.race-figure{position:absolute;inset:0;transform-origin:50% 100%}
.race-face{position:absolute;left:3px;top:2px;width:34px;height:34px;z-index:2}
.race-face .gh-face,.race-face svg{display:block;width:100%;height:100%}
.race-initial{display:grid;place-items:center;width:100%;height:100%;border-radius:50%;background:#e4e9da;font-weight:750}
.race-body{position:absolute;left:14px;top:33px;width:12px;height:8px;border-radius:5px 5px 3px 3px;background:var(--shirt);z-index:1}
.race-leg{position:absolute;top:6px;width:3px;height:9px;border-radius:2px;background:#33423a;transform-origin:50% 0}
.race-leg.left{left:2px;animation:race-leg .24s ease-in-out var(--start) var(--legs) alternate}
.race-leg.right{right:2px;animation:race-leg .24s ease-in-out calc(var(--start) + .12s) var(--legs) alternate-reverse}
.race-gain{position:absolute;left:calc(100% - 2px);top:4px;font-size:.78rem;font-weight:800;color:#9a5a1d;background:#fff4d6;border-radius:8px;padding:0 5px;white-space:nowrap;opacity:0;animation:race-pop .5s cubic-bezier(.2,1.6,.4,1) calc(var(--arrive) - .05s) both}
/* Near the line the gain sits on the runner's left, clear of the finish. */
.near-line .race-gain{left:auto;right:calc(100% - 2px)}
.mood-out .race-gain{right:calc(100% + 14px)}
.race-prop{position:absolute;z-index:3;font-size:16px;line-height:1;opacity:0;pointer-events:none}
.race-bubble{display:none}
.race-headline{margin-top:10px;text-align:center;font-weight:700;font-size:1.06rem;opacity:0;animation:race-fade .5s ease-out var(--headline) both}
.race-summary{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
/* Continue stays in reach at the bottom of the card when many lanes scroll. */
.race-foot{position:sticky;bottom:0;z-index:5;padding:10px 0 14px;background:#fffdf6}
.race-continue{display:flex;margin:0 auto;min-width:160px}

/* One at a time: the running lane lights up and its runner mutters on the way. */
.race-overlay.solo .race-lane::before{content:"";position:absolute;inset:0 -6px;border-radius:10px;background:#f6e9c8;z-index:-1;opacity:0;animation:race-spot calc(var(--run) + 1s) ease-in-out var(--start) both}
.race-overlay.solo .race-bubble{display:block;position:absolute;bottom:calc(100% + 2px);left:50%;transform-origin:0 100%;font-size:.76rem;font-weight:700;font-style:italic;white-space:nowrap;background:#fff;color:#203a31;border:1px solid #d6dccd;border-radius:10px 10px 10px 2px;padding:2px 7px;box-shadow:0 2px 6px #12302612;opacity:0;animation:race-bubble calc(var(--run) + .7s) ease-out var(--start) both}
.race-overlay.solo .near-line .race-bubble{left:auto;right:50%;border-radius:10px 10px 2px 10px;transform-origin:100% 100%}

/* Moods, shown once each runner arrives. */
/* Props sit on or beside the head, inside the lane, clear of the name and caption above. */
.mood-champion .race-prop{left:10px;top:1px;font-size:16px;animation:race-crown .6s cubic-bezier(.2,1.4,.4,1) calc(var(--arrive) + .05s) both}
.mood-champion .race-figure{animation:race-hop .34s ease-out calc(var(--arrive) + .45s) 4 alternate}
.mood-out .race-caption{color:#a2392b}
.mood-fuming .race-face{animation:race-stomp .16s ease-in-out calc(var(--arrive) + .05s) 10 alternate}
.mood-fuming .race-prop{right:-12px;top:4px;animation:race-pop .4s cubic-bezier(.2,1.6,.4,1) var(--arrive) both}
.mood-fuming .race-face::after{content:"";position:absolute;inset:2px;border-radius:50%;background:radial-gradient(circle,#ef4b3a66,#ef4b3a00 70%);opacity:0;animation:race-fade .4s ease-out var(--arrive) both}
.race-steam{position:absolute;left:4px;top:-2px;width:28px;height:10px;z-index:3;pointer-events:none}
.race-steam i{position:absolute;bottom:0;width:8px;height:8px;border-radius:50%;background:#f3f1ec;box-shadow:0 0 0 1px #d6d2c8;opacity:0;animation:race-steam .8s ease-out calc(var(--arrive) + .1s) 3}
.race-steam i:first-child{left:0}.race-steam i:last-child{right:0;animation-delay:calc(var(--arrive) + .3s)}
.mood-fuming .race-caption{color:#a2392b}
.mood-smug .race-prop{left:5px;top:8px;font-size:17px;animation:race-shades .5s ease-out calc(var(--arrive) + .05s) both}
.mood-smug .race-figure{animation:race-lean .5s ease-out calc(var(--arrive) + .5s) both}
.mood-nervous .race-figure{animation:race-tremble .09s linear calc(var(--arrive) + .05s) 22 alternate}
.mood-nervous .race-prop{right:-6px;top:0;animation:race-sweat .7s ease-in calc(var(--arrive) + .1s) 3}
.mood-nervous .race-caption{color:#9a5a1d}
.mood-ouch .race-figure{animation:race-stumble .6s ease-out calc(var(--arrive) + .05s) both}
.mood-ouch .race-prop{right:-10px;top:8px;animation:race-pop .4s cubic-bezier(.2,1.6,.4,1) var(--arrive) both}
.mood-relaxed .race-figure{animation:race-recline .6s ease-out calc(var(--arrive) + .05s) both}
.mood-relaxed .race-prop{right:-10px;top:0;animation:race-float 1.2s ease-out calc(var(--arrive) + .3s) 2}
.mood-happy .race-figure{animation:race-hop .3s ease-out calc(var(--arrive) + .05s) 6 alternate}
.mood-steady .race-face{animation:race-nod .4s ease-in-out calc(var(--arrive) + .05s) 2 alternate}
/* After arriving, each runner keeps a small bounce where it stopped (owner
   request, 2026-10-17), lanes slightly out of step; it moves only and stops
   after about two minutes. The one who fell over stays down, stars circling. */
.race-hopper{animation:race-bounce 1.4s cubic-bezier(.3,0,.5,1) calc(var(--arrive) + 1.9s + var(--i) * .13s) 85}
.mood-out .race-hopper{animation:none}

/* Over the limit: a comic fate at the finish line (owner request,
   2026-10-18), picked in race.js. The actor (and sometimes a second prop)
   appears as the runner arrives; like everything here it only moves or
   fades, runs once and ends still. Flights go up or left, so nothing is
   left hanging off the card. */
.race-fate,.race-fate-extra{position:absolute;left:-6px;top:-2px;width:52px;height:52px;display:flex;align-items:center;justify-content:center;font-size:30px;line-height:1;opacity:0;pointer-events:none;z-index:4}
.race-fate-extra{font-size:22px;z-index:3}
/* A rocket fizzes under the runner, then both blast off upwards. */
.fate-rocket .race-fate{animation:fate-rocket 2.3s linear calc(var(--arrive) + .1s) both}
.fate-rocket .race-figure{animation:fate-rocket-ride 2.3s linear calc(var(--arrive) + .1s) both}
.fate-rocket .race-fate-extra{animation:fate-puff 2.3s ease-out calc(var(--arrive) + .1s) both}
/* A flying saucer hovers, beams the runner up and zooms off. */
.fate-ufo .race-fate{animation:fate-ufo 2.7s ease-in-out calc(var(--arrive) + .1s) both}
.fate-ufo .race-figure{animation:fate-beam 2.7s ease-in-out calc(var(--arrive) + .1s) both}
/* A hole opens at the runner's feet and swallows them. */
.fate-hole .race-fate{animation:fate-hole .5s cubic-bezier(.2,1.4,.4,1) calc(var(--arrive) + .1s) both}
.fate-hole .race-figure{animation:fate-drop 1.5s ease-in calc(var(--arrive) + .1s) both}
/* Two balloons appear and float the runner off. */
.fate-balloons .race-fate{animation:fate-balloon 3.3s ease-in-out calc(var(--arrive) + .1s) both}
.fate-balloons .race-fate-extra{font-size:28px;animation:fate-balloon-two 3.3s ease-in-out calc(var(--arrive) + .1s) both}
.fate-balloons .race-figure{animation:fate-float 3.3s ease-in-out calc(var(--arrive) + .1s) both}

@keyframes race-in{from{opacity:0}to{opacity:1}}
@keyframes race-out{to{opacity:0}}
@keyframes race-fade{from{opacity:0}to{opacity:1}}
@keyframes race-run{from{transform:translateX(calc(6cqw + var(--from) * 82cqw - 50%))}to{transform:translateX(calc(6cqw + var(--to) * 82cqw - 50%))}}
@keyframes race-leg{from{transform:rotate(-32deg)}to{transform:rotate(32deg)}}
@keyframes race-pop{from{opacity:0;transform:scale(.4)}to{opacity:1;transform:scale(1)}}
@keyframes race-spot{0%{opacity:0}15%{opacity:.9}80%{opacity:.9}100%{opacity:0}}
@keyframes race-bubble{0%{opacity:0;transform:scale(.5)}12%{opacity:1;transform:scale(1)}85%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.9)}}
@keyframes race-crown{from{opacity:0;transform:translateY(-22px)}to{opacity:1;transform:translateY(0)}}
@keyframes race-hop{from{transform:translateY(0)}to{transform:translateY(-7px)}}
@keyframes fate-rocket{0%{opacity:0;transform:translate(0,20px) rotate(-45deg) scale(.4)}10%{opacity:1;transform:translate(0,18px) rotate(-45deg) scale(1)}16%{transform:translate(-2px,18px) rotate(-45deg) scale(1)}22%{transform:translate(2px,18px) rotate(-45deg) scale(1)}28%{transform:translate(-2px,18px) rotate(-45deg) scale(1)}34%{transform:translate(0,18px) rotate(-45deg) scale(1);animation-timing-function:cubic-bezier(.5,0,1,.6)}90%{opacity:1}100%{opacity:0;transform:translate(-40px,-300px) rotate(-45deg) scale(1)}}
@keyframes fate-rocket-ride{0%,16%{opacity:1;transform:translate(0,0)}22%{transform:translate(1px,0)}28%{transform:translate(-1px,0)}34%{opacity:1;transform:translate(0,0);animation-timing-function:cubic-bezier(.5,0,1,.6)}90%{opacity:1}100%{opacity:0;transform:translate(-40px,-318px)}}
@keyframes fate-puff{0%,32%{opacity:0;transform:translate(0,22px) scale(.4)}44%{opacity:1;transform:translate(0,22px) scale(1.2)}100%{opacity:0;transform:translate(8px,16px) scale(1.7)}}
@keyframes fate-ufo{0%{opacity:0;transform:translate(0,-160px)}15%{opacity:1;transform:translate(0,-50px)}25%{transform:translate(-3px,-48px)}35%{transform:translate(3px,-50px)}45%{transform:translate(-3px,-48px)}55%{transform:translate(3px,-50px)}68%{opacity:1;transform:translate(0,-48px)}100%{opacity:0;transform:translate(-150px,-260px)}}
@keyframes fate-beam{0%,22%{opacity:1;transform:translateY(0) scale(1)}55%{opacity:1;transform:translateY(-34px) scale(.45)}62%,100%{opacity:0;transform:translateY(-40px) scale(.3)}}
@keyframes fate-hole{from{opacity:0;transform:translate(0,22px) scale(.2,.1)}to{opacity:1;transform:translate(0,22px) scale(1.3,.6)}}
@keyframes fate-drop{0%,30%{opacity:1;transform:translateY(0) scale(1)}40%{transform:translateY(-10px) scale(1)}75%{opacity:1;transform:translateY(12px) scale(.5)}85%,100%{opacity:0;transform:translateY(16px) scale(.2)}}
@keyframes fate-balloon{0%{opacity:0;transform:translate(-8px,-30px) scale(.2)}15%{opacity:1;transform:translate(-8px,-40px) scale(1)}35%{transform:translate(-8px,-40px) scale(1)}55%{transform:translate(-14px,-122px) scale(1)}75%{transform:translate(-2px,-212px) scale(1)}90%{opacity:1}100%{opacity:0;transform:translate(-30px,-322px) scale(1)}}
@keyframes fate-balloon-two{0%{opacity:0;transform:translate(10px,-26px) scale(.2)}18%{opacity:1;transform:translate(10px,-34px) scale(1)}35%{transform:translate(10px,-34px) scale(1)}55%{transform:translate(4px,-116px) scale(1)}75%{transform:translate(16px,-206px) scale(1)}90%{opacity:1}100%{opacity:0;transform:translate(-12px,-316px) scale(1)}}
@keyframes fate-float{0%,35%{opacity:1;transform:translate(0,0) rotate(0)}55%{transform:translate(-6px,-82px) rotate(-6deg)}75%{transform:translate(6px,-172px) rotate(6deg)}90%{opacity:1}100%{opacity:0;transform:translate(-22px,-282px) rotate(0)}}
@keyframes race-bounce{0%,60%,100%{transform:translateY(0)}28%{transform:translateY(-5px)}}
@keyframes race-stomp{from{transform:translateY(0)}to{transform:translateY(2px)}}
@keyframes race-steam{0%{opacity:.9;transform:translateY(0) scale(.6)}100%{opacity:0;transform:translateY(-10px) scale(1.3)}}
@keyframes race-shades{from{opacity:0;transform:translateY(-16px)}to{opacity:1;transform:translateY(0)}}
@keyframes race-lean{to{transform:rotate(-9deg)}}
@keyframes race-tremble{from{transform:translateX(-1.4px)}to{transform:translateX(1.4px)}}
@keyframes race-sweat{0%{opacity:1;transform:translate(0,0)}100%{opacity:0;transform:translate(6px,16px)}}
@keyframes race-stumble{0%{transform:rotate(0)}35%{transform:rotate(22deg) translateX(4px)}70%{transform:rotate(-6deg)}100%{transform:rotate(0)}}
@keyframes race-recline{to{transform:rotate(-16deg) translateY(2px)}}
@keyframes race-float{0%{opacity:0;transform:translate(0,0)}25%{opacity:1}100%{opacity:0;transform:translate(8px,-16px)}}
@keyframes race-nod{from{transform:rotate(-4deg)}to{transform:rotate(4deg)}}

/* Seven to ten players: tighter lanes so everyone fits on a phone. */
.race-overlay.many .race-fate{font-size:24px;width:44px;height:44px;left:-6px;top:-4px}
.race-overlay.many .race-track{height:42px}.race-overlay.many .race-lanes{gap:1px}.race-overlay.many .race-lane-head{font-size:.78rem}
.race-overlay.many .race-sub{display:none}.race-overlay.many .race-runner{height:38px;width:32px}.race-overlay.many .race-face{width:27px;height:27px;left:2px}
.race-overlay.many .race-body{top:25px;left:10px}.race-overlay.many .race-leg{height:8px}
/* Narrow phones: the caption gives way to the name and score first. */
@media (max-width:380px){.race-lane-head{font-size:.8rem;gap:5px}.race-overlay.many .race-lane-head{font-size:.74rem}.race-gain{font-size:.72rem}}
/* Short screens (landscape phones): tighter lanes so ten players still fit. */
@media (max-height:520px){.race-card{padding:10px 12px 0}.race-foot{padding:6px 0 10px}.race-head{margin-bottom:4px}.race-head h2{font-size:1.3rem}.race-sub{display:none}.race-lane-head{font-size:.76rem}.race-track{height:38px}.race-runner{height:36px;width:32px}.race-face{width:26px;height:26px;left:3px}.race-body{top:24px;left:10px}.race-continue{min-height:38px}}
/* Big screens (the TV): larger faces and text. */
@media (min-width:1100px) and (min-height:700px){.race-card{width:min(92vw,1100px);padding:26px 30px 0}.race-foot{padding-bottom:24px}.race-lane-head{font-size:1.15rem}.race-gain{font-size:.95rem}.race-line{font-size:.9rem}.race-track{height:70px}.race-runner{width:56px;height:64px}.race-face{width:48px;height:48px;left:4px}.race-body{top:44px;left:19px;width:18px;height:11px}.race-leg{height:12px;top:9px;width:4px}.race-prop{font-size:24px}.race-overlay.solo .race-bubble{font-size:1rem}.race-headline{font-size:1.4rem}
  .race-overlay.many .race-track{height:56px}.race-overlay.many .race-runner{width:46px;height:54px}.race-overlay.many .race-face{width:40px;height:40px;left:3px}.race-overlay.many .race-body{top:38px;left:16px}.race-overlay.many .race-leg{height:10px}
  .race-fate,.race-overlay.many .race-fate{font-size:44px;width:72px;height:72px;left:-8px;top:-6px}.race-fate-extra{font-size:30px;width:72px;height:72px;left:-8px;top:-6px}}
@media (prefers-reduced-motion:reduce){.race-overlay,.race-overlay *{animation:none!important}.race-caption,.race-headline,.race-gain{opacity:1}}
