/* Photo Finish (reading to the end of a word): the track fills the screen (the stand with the word and
   the finish-line camera on top, three lanes below), the three runner bibs in a row underneath. The
   word's ending sits behind the finish line (.pf-gate, checkered) until the photo. Everything he taps
   is at least 90px; no hover needed. */
.game.photofinish { background: linear-gradient(#bfe6ff, #eaf6ff 45%, #e3f4da); }
.photofinish button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.photofinish .game-top { padding-top: 5px; padding-bottom: 5px; }
.photofinish .pf-back { min-height: 60px; min-width: 60px; white-space: nowrap; }
.photofinish .pf-count { white-space: nowrap; }
.photofinish .pf-count i { font-style: normal; }
.photofinish .pf-body {
  flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 14px max(16px, env(safe-area-inset-left, 0px));
}
.photofinish { --check: repeating-conic-gradient(#2d2d3a 0 25%, #fff 0 50%); --line: 76%; --fs: clamp(56px, min(13vw, 13vh), 120px); }

/* ---------- the track ---------- */
.photofinish .pf-track {
  flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden;
  border: 4px solid var(--ink); border-radius: 26px; box-shadow: var(--shadow); background: #a9dcff;
}
.photofinish .pf-stand { flex: 1; min-height: 0; position: relative; background: linear-gradient(#8fd0ff, #d4eeff); }
.photofinish .pf-crowd { position: absolute; left: 0; bottom: 0; width: 100%; height: 72%; display: block; }
.photofinish .pf-crowd .pf-wave { animation: pf-wave 1.4s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 0 100%; }
.photofinish .pf-pennants { position: absolute; left: 0; top: 0; width: 100%; height: 22px; display: block; }

/* the heats: a medal for each one won */
.photofinish .pf-heats { position: absolute; left: 12px; top: 28px; z-index: 2; display: flex; gap: 4px; }
.photofinish .pf-heats i {
  display: grid; place-items: center; width: 28px; height: 28px; font-style: normal; font-size: 17px; line-height: 1;
  background: rgba(255, 255, 255, .9); border: 3px solid var(--ink); border-radius: 50%;
}
.photofinish .pf-heats i.now { background: #ffd23f; animation: pf-now 1.2s ease-in-out infinite; }
.photofinish .pf-heats i.gold, .photofinish .pf-heats i.silver { background: #fff; animation: pf-pop .4s cubic-bezier(.2, 1.6, .4, 1); }

.photofinish .pf-hear {
  position: absolute; left: 12px; top: calc(50% + 24px); transform: translateY(-50%); z-index: 4; width: 76px; height: 76px; padding: 0;
  border-radius: 50%; border: 4px solid var(--ink); background: #fff8d6; font-size: 34px; line-height: 1; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); cursor: pointer;
}
.photofinish .pf-hear:active:not(:disabled) { transform: translateY(-50%) scale(.92); }
.photofinish .pf-hear:disabled { opacity: .45; cursor: default; }
.photofinish .pf-hear.wiggle { animation: pf-wiggle .5s ease-in-out 2; }

/* the word: what he sees, up to the finish line... */
.photofinish .pf-word {
  position: absolute; right: calc(100% - var(--line)); top: calc(50% + 24px); transform: translateY(-50%); z-index: 3;
  font-size: var(--fs); font-weight: 700; line-height: 1.2;
}
.photofinish .pf-plate {
  display: flex; align-items: center; height: calc(1.2em + 8px); padding: 0 .1em 0 .18em; color: var(--ink);
  background: #fff; border: 4px solid var(--ink); border-right: 0; border-radius: .2em 0 0 .2em; box-shadow: 0 5px 0 rgba(58, 42, 74, .25);
}
.photofinish .pf-plate.slide { animation: pf-slide .65s cubic-bezier(.2, .9, .3, 1.12) both; }
.photofinish .pf-ch { display: inline-block; }
.photofinish .pf-word.sweep .pf-ch { animation: pf-lit .55s ease-out both; animation-delay: calc(var(--i) * 230ms); }
.photofinish .pf-trophy { font-size: .8em; animation: pf-jump .8s ease-in-out infinite; }
/* ...and its ending, behind the line */
.photofinish .pf-gate {
  position: absolute; left: var(--line); top: calc(50% + 24px); transform: translateY(-50%); z-index: 3;
  display: flex; align-items: center; justify-content: center; min-width: 1.45em; height: calc(1.2em + 8px); padding: 0 .08em;
  font-size: var(--fs); font-weight: 700; line-height: 1.2; color: var(--ink);
  background: var(--check) 0 0 / .3em .3em; border: 4px solid var(--ink); border-radius: 0 .2em .2em 0; box-shadow: 0 5px 0 rgba(58, 42, 74, .25);
}
.photofinish .pf-q {
  display: grid; place-items: center; width: 1.25em; height: 1.25em; font: 800 .5em/1 var(--font); font-style: normal; color: var(--ink);
  background: #ffd23f; border: 4px solid var(--ink); border-radius: 50%;
}
.photofinish .pf-gate.sweep .pf-q { animation: pf-ping .6s ease-out both; animation-delay: calc(var(--i) * 230ms); }
.photofinish .pf-end { display: none; }
.photofinish .pf-gate.open { background: #fff; animation: pf-land .35s cubic-bezier(.2, 1.6, .4, 1); }
.photofinish .pf-gate.open .pf-q { display: none; }
.photofinish .pf-gate.open .pf-end { display: inline; }
.photofinish .pf-gate.ok { background: #dcf8e3; color: #1d8a4f; }
.photofinish .pf-gate.bad { background: #ffe1e3; color: #d6333a; }
.photofinish .pf-gate.hide { visibility: hidden; }
.photofinish .pf-post { position: absolute; left: var(--line); top: calc(50% + 24px); bottom: 0; width: 14px; z-index: 1; background: var(--check) 0 0 / 14px 14px; border: 2px solid var(--ink); border-bottom: 0; }

.photofinish .pf-cam { position: absolute; right: 10px; top: 8px; z-index: 2; width: clamp(56px, 8vw, 92px); }
.photofinish .pf-camsvg { display: block; width: 100%; height: auto; }
.photofinish .pf-cam.snap { animation: pf-snap .4s ease-out; }
.photofinish .pf-cam.snap .pf-bulb { animation: pf-bulb .5s ease-out; }

/* the lanes and the runners */
.photofinish .pf-lanes {
  flex: none; position: relative; z-index: 2; display: flex; flex-direction: column; height: clamp(150px, min(36vh, 56vw), 340px);
  background: #d8623f; border-top: 4px solid var(--ink);
}
.photofinish .pf-lane { flex: 1; border-bottom: 3px solid rgba(255, 255, 255, .85); }
.photofinish .pf-lane:last-of-type { border-bottom: 0; }
.photofinish .pf-line { position: absolute; left: var(--line); top: 0; bottom: 0; width: 14px; background: var(--check) 0 0 / 14px 14px; }
.photofinish .pf-runner {
  position: absolute; left: calc(var(--x, 10) * 1%); transform: translateX(-50%); z-index: 2;
  transition: left 1.15s cubic-bezier(.45, .05, .45, 1), opacity .25s;
}
.photofinish .pf-runner.reset { transition: none; }
.photofinish .pf-runner.back { opacity: 0; }
.photofinish .pf-runner.lane0 { height: 37%; aspect-ratio: 1; bottom: 68%; }
.photofinish .pf-runner.lane1 { height: 44%; aspect-ratio: 1; bottom: 36%; z-index: 3; }
.photofinish .pf-runner.me { height: 52%; aspect-ratio: 140 / 225; bottom: 3%; z-index: 4; container-type: size; }
.photofinish .pf-rbody { position: relative; width: 100%; height: 100%; }
.photofinish .pf-rbody > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.photofinish .pf-runner.run .pf-rbody { animation: pf-bob .22s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.photofinish .pf-runner.party .pf-rbody { animation: pf-jump .7s ease-in-out infinite; }
.photofinish .pf-runner.lane1.party .pf-rbody { animation-delay: .2s; }
.photofinish .pf-runner.lane0.party .pf-rbody { animation-delay: .4s; }
/* the bib he picked, on his runner */
.photofinish .pf-mybib {
  position: absolute; left: 50%; top: 52%; min-width: 34%; padding: 0 5%; transform: translateX(-50%) scale(0);
  font-size: 16px; font-size: 13cqh; font-weight: 700; line-height: 1.15; text-align: center; color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 5px; transition: transform .2s cubic-bezier(.2, 1.6, .4, 1);
}
.photofinish .pf-mybib.on { transform: translateX(-50%) scale(1); }

/* the photo from the finish-line camera */
.photofinish .pf-flash { position: absolute; inset: 0; z-index: 25; background: #fff; opacity: 0; pointer-events: none; }
.photofinish .pf-flash.go { animation: pf-flash .55s ease-out; }
.photofinish .pf-photo { position: absolute; inset: 0; z-index: 20; display: none; place-items: center; padding: 12px; pointer-events: none; }
.photofinish .pf-photo.show { display: grid; }
.photofinish .pf-polaroid {
  display: flex; flex-direction: column; align-items: center; width: min(380px, 80%); max-height: 100%; padding: 10px 10px 2px;
  background: #fff; border: 4px solid var(--ink); border-radius: 10px; box-shadow: 0 10px 0 rgba(0, 0, 0, .2);
  animation: pf-photo .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
.photofinish .pf-photo.gone .pf-polaroid { animation: pf-photo-out .3s ease-in forwards; }
.photofinish .pf-snap {
  position: relative; width: 100%; aspect-ratio: 16 / 10; min-height: 0; overflow: hidden; border: 3px solid var(--ink);
  background: linear-gradient(#cfe6ff, #efe3cb 58%, #d8623f 58%); filter: sepia(.2) saturate(1.1);
}
.photofinish .pf-sline { position: absolute; left: 64%; top: 0; bottom: 0; width: 7%; background: var(--check) 0 0 / 12px 12px; }
.photofinish .pf-swho { position: absolute; left: 36%; bottom: 3%; height: 90%; aspect-ratio: 140 / 225; transform: translateX(-50%); }
.photofinish .pf-polaroid.bad .pf-swho { aspect-ratio: 1; height: 70%; left: 52%; }
.photofinish .pf-swho > svg { display: block; width: 100%; height: 100%; }
.photofinish .pf-spic { position: absolute; right: 5%; top: 6%; font-size: clamp(30px, 5vw, 54px); line-height: 1; }
.photofinish .pf-sfirst {
  position: absolute; left: 5%; top: 7%; display: grid; place-items: center; width: 2.3em; height: 2.3em; font-size: clamp(15px, 2vw, 20px);
  color: var(--ink); background: #ffd23f; border: 3px solid var(--ink); border-radius: 50%; transform: rotate(-12deg);
}
.photofinish .pf-cap { font-size: clamp(44px, min(8vw, 9vh), 84px); font-weight: 700; line-height: 1.25; color: var(--ink); }
.photofinish .pf-cap b { color: var(--good); text-decoration: underline .07em; text-underline-offset: .1em; }
.photofinish .pf-polaroid.bad .pf-cap b { color: #d6333a; background: #ffe1e3; border-radius: .12em; padding: 0 .04em; text-decoration: none; }

/* ---------- the bibs ---------- */
.photofinish .pf-pick { flex: none; display: flex; justify-content: center; gap: clamp(10px, 3vw, 28px); }
.photofinish .pf-bib {
  --band: #e8553f; position: relative; width: clamp(100px, 27vw, 210px); height: clamp(100px, 17vh, 150px); padding: 0; overflow: hidden;
  font: inherit; color: var(--ink); background: linear-gradient(var(--band) 0 21%, var(--ink) 21% calc(21% + 3px), #fff calc(21% + 3px));
  border: 4px solid var(--ink); border-radius: 14px 14px 24px 24px; box-shadow: var(--shadow); cursor: pointer; opacity: 0;
  transition: opacity .2s, transform .15s, box-shadow .15s;
}
.photofinish .pf-bib.c1 { --band: #1d7fd0; }
.photofinish .pf-bib.c2 { --band: #3fa34d; }
.photofinish .pf-pin { position: absolute; top: 6%; width: 12px; height: 12px; border-radius: 50%; background: #d7dbe3; border: 2px solid var(--ink); }
.photofinish .pf-pin.l { left: 9%; }
.photofinish .pf-pin.r { right: 9%; }
.photofinish .pf-btext { display: block; margin-top: 10%; font-size: clamp(48px, min(8vw, 9vh), 84px); font-weight: 700; line-height: 1; pointer-events: none; }
.photofinish .pf-bib.show { opacity: 1; animation: pf-bib-in .35s cubic-bezier(.2, 1.5, .4, 1) backwards; }
.photofinish .pf-bib.c1.show { animation-delay: .07s; }
.photofinish .pf-bib.c2.show { animation-delay: .14s; }
.photofinish .pf-bib.none { display: none; }
.photofinish .pf-bib:disabled { cursor: default; }
.photofinish .pf-bib.show:active:not(:disabled) { transform: scale(.95); }
.photofinish .pf-bib.picked { background-color: #fff8d6; transform: translateY(-6px); box-shadow: 0 0 0 5px #ffd23f, var(--shadow); }
.photofinish .pf-bib.out { opacity: .35; }
.photofinish .pf-bib.out::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top right, transparent 46%, #d6333a 46% 54%, transparent 54%); }
.photofinish .pf-bib.gone { opacity: 0; transform: scale(.9); }
@media (hover: hover) { .photofinish .pf-bib.show:hover:not(:disabled) { transform: translateY(-3px); } }

/* ---------- before the first heat ---------- */
.photofinish .pf-start { position: absolute; inset: 0; z-index: 30; display: none; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 14px; overflow: auto; background: rgba(30, 40, 70, .35); }
.photofinish .pf-start.show { display: grid; }
.photofinish .pf-card {
  width: min(520px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px 20px 22px; text-align: center;
  background: #fff; border: 4px solid var(--ink); border-radius: 28px; box-shadow: var(--shadow);
}
.photofinish .pf-hero { display: flex; align-items: flex-end; justify-content: center; gap: 8px; height: min(130px, 17vh); }
.photofinish .pf-hme { height: 100%; aspect-ratio: 140 / 225; animation: pf-jump 1.2s ease-in-out infinite; }
.photofinish .pf-hme > svg { display: block; width: 100%; height: 100%; }
.photofinish .pf-hline { width: 16px; height: 100%; background: var(--check) 0 0 / 16px 16px; border: 2px solid var(--ink); }
.photofinish .pf-hcam { height: 62%; align-self: flex-start; }
.photofinish .pf-hcamsvg { display: block; height: 100%; width: auto; }
.photofinish .pf-demo { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.photofinish .pf-dword { display: flex; align-items: stretch; font-size: 52px; font-weight: 700; line-height: 1.2; color: var(--ink); }
.photofinish .pf-dword > span { padding: 0 6px 0 10px; background: #fff; border: 4px solid var(--ink); border-right: 0; border-radius: 12px 0 0 12px; }
.photofinish .pf-dgate { display: grid; place-items: center; min-width: 1.4em; background: var(--check) 0 0 / 16px 16px; border: 4px solid var(--ink); border-radius: 0 12px 12px 0; }
.photofinish .pf-dbibs { display: flex; gap: 10px; }
.photofinish .pf-dbibs span {
  --band: #e8553f; display: grid; place-items: end center; width: 58px; height: 60px; padding-bottom: 2px; font-size: 32px; font-weight: 700; line-height: 1; color: var(--ink);
  background: linear-gradient(var(--band) 0 22%, #fff 22%); border: 3px solid var(--ink); border-radius: 8px 8px 14px 14px;
}
.photofinish .pf-dbibs span:nth-child(2) { --band: #1d7fd0; }
.photofinish .pf-dbibs span:nth-child(3) { --band: #3fa34d; }
.photofinish .pf-go {
  min-height: 84px; padding: 6px 44px; font: inherit; font-size: 34px; font-weight: 800; color: #fff; background: #e8553f;
  border: 4px solid var(--ink); border-radius: 999px; box-shadow: var(--shadow); cursor: pointer;
}
.photofinish .pf-go:active { transform: scale(.95); }
.photofinish .pf-off { margin: 0; font-weight: 700; color: var(--coral-dark); }
.photofinish .pf-off .btn { min-height: 48px; }

/* the words he finished, on the results card */
.results .pf-res { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 380px; margin: 0 auto; }
.results .pf-res > span { padding: 0 8px; background: #fff; border: 3px solid #d9d9e3; border-radius: 10px; }
.results .pf-res > span.gold { background: #fff8d6; border-color: #f2b705; }
.results .pf-res i { font-style: normal; font-size: 22px; font-weight: 700; }
.results .pf-res b { color: var(--good); }

/* ---------- a tall screen (an iPad held up, a phone) ---------- */
@media (max-aspect-ratio: 1/1) {
  .photofinish { --line: 72%; }
}
@media (max-width: 560px) {
  .photofinish { --line: 70%; --fs: clamp(50px, 15vw, 62px); }
  .photofinish .game-top h2 { font-size: 20px; }
  .photofinish .hud span { font-size: 16px; padding: 0 8px; }
  .photofinish .pf-hw { display: none; }
  .photofinish .pf-body { padding-top: 8px; padding-bottom: 10px; gap: 10px; }
  .photofinish .pf-track { border-radius: 22px; }
  .photofinish .pf-hear { left: 8px; width: 62px; height: 62px; font-size: 28px; }
  .photofinish .pf-heats { left: 8px; gap: 3px; }
  .photofinish .pf-heats i { width: 24px; height: 24px; font-size: 14px; border-width: 2px; }
  .photofinish .pf-cam { width: 50px; }
  .photofinish .pf-q { border-width: 3px; }
  .photofinish .pf-hero { height: 96px; }
  .photofinish .pf-dword { font-size: 44px; }
}

@keyframes pf-slide { from { transform: translateX(-120vw); } }
@keyframes pf-lit { 35% { color: #e8553f; transform: translateY(-.1em) scale(1.12); text-shadow: 0 0 .25em #ffd23f; } }
@keyframes pf-ping { 40% { transform: scale(1.35); box-shadow: 0 0 0 .2em rgba(255, 210, 63, .6); } }
@keyframes pf-land { from { transform: translateY(-50%) scale(1.4); } }
@keyframes pf-pop { from { transform: scale(1.7); } }
@keyframes pf-now { 50% { box-shadow: 0 0 0 4px rgba(255, 210, 63, .55); } }
@keyframes pf-wiggle { 25% { transform: translateY(-50%) rotate(-12deg); } 75% { transform: translateY(-50%) rotate(12deg); } }
@keyframes pf-bob { from { transform: translateY(0) rotate(-5deg); } to { transform: translateY(-9%) rotate(5deg); } }
@keyframes pf-jump { 50% { transform: translateY(-14%); } }
@keyframes pf-wave { to { transform: rotate(-30deg); } }
@keyframes pf-flash { from { opacity: .95; } to { opacity: 0; } }
@keyframes pf-snap { 30% { transform: scale(1.12) rotate(-4deg); } }
@keyframes pf-bulb { 0%, 40% { fill: #fff; filter: drop-shadow(0 0 6px #fff); } }
@keyframes pf-photo { from { transform: scale(.3) rotate(-14deg); opacity: 0; } to { transform: rotate(-3deg); opacity: 1; } }
@keyframes pf-photo-out { from { transform: rotate(-3deg); } to { transform: translateY(30%) scale(.6) rotate(6deg); opacity: 0; } }
@keyframes pf-bib-in { from { transform: translateY(40%) scale(.7); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .photofinish .pf-crowd .pf-wave, .photofinish .pf-heats i.now, .photofinish .pf-runner .pf-rbody, .photofinish .pf-hme, .photofinish .pf-trophy { animation: none !important; }
  .photofinish .pf-flash.go { animation-duration: .3s; }
}
