/* At the Races big screen (main screen), everything except the race itself: the betting carousel,
   results, who backed who, the lobby/ready screens. Top three and the final leaderboard use the shell
   (16_main_shell.css). Sizes are "stage pixels". */

body.gtf,
.gtf-screen--races {
  --gtf-rs-horse: oklch(0.4 0.09 145);
  --gtf-rs-reindeer: oklch(0.82 0.03 230);
  --gtf-rs-alpaca: oklch(0.58 0.09 75);
  --gtf-rs-grandpa: oklch(0.5 0.07 300);
}

/* The design's header for these stages: 100px high, 36px from the top, race title at 40px. */
.gtf-screen--races .gtf-screen__header {
  top: 36px;
  height: 100px;
}

.gtf-screen--races .gtf-screen__title { font-size: 52px; }
.gtf-screen--races .gtf-screen__heading { font-size: 40px; }

/* Who backed who starts higher and runs closer to the bottom edge than the other stages. */
.gtf-screen--races .gtf-screen__body:has(.gtf-rbets) { inset: 160px 64px 36px 64px; }

/* ---------- Racer sprite (first idle frame of the sheet, facing the finish) ---------- */

.gtf-rsprite {
  --h: 120px;
  --surface: var(--gtf-rs-horse);
  position: relative;
  display: inline-block;
  flex: none;
  height: var(--h);
  width: calc(var(--h) * var(--ratio, 1.1));
  font-size: calc(var(--h) * 0.09);
}

.gtf-rsprite[data-animal="reindeer"] { --surface: var(--gtf-rs-reindeer); }
.gtf-rsprite[data-animal="alpaca"] { --surface: var(--gtf-rs-alpaca); }
.gtf-rsprite[data-animal="grandpa"] { --surface: var(--gtf-rs-grandpa); }

.gtf-rsprite--hero { --h: 493px; }
.gtf-rsprite--podium { --h: 210px; }
.gtf-rsprite--podium_small { --h: 170px; }
.gtf-rsprite--small { --h: 100px; }
.gtf-rsprite--phone { --h: 88px; font-size: 9px; }

.gtf-rpod--dense .gtf-rsprite--podium { --h: 170px; }
.gtf-rpod--dense .gtf-rsprite--podium_small { --h: 140px; }
.gtf-rpod--dense .gtf-rsprite--small { --h: 76px; }

.gtf-rsprite--backdrop::before {
  content: "";
  position: absolute;
  top: 4%;
  bottom: 4%;
  left: 50%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50% 50% 14px 14px;
  background: var(--surface);
}

.gtf-rsprite__shadow {
  position: absolute;
  left: 17%;
  bottom: 4%;
  width: 66%;
  height: 7%;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.28);
}

.gtf-rsprite__img {
  position: absolute;
  inset: 0;
  background: var(--sheet) 0 0 / 500% 500% no-repeat;
}

.gtf-rsprite__saddle {
  position: absolute;
  left: 28%;
  top: 49%;
  width: 20%;
  height: 14%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gtf-ink);
  font-weight: 900;
  line-height: 1;
  transform: rotate(-5deg);
}

/* The design's saddle cloth: a curved blanket with a dark band along the top. */
.gtf-rsprite__cloth {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gtf-rsprite[data-animal="reindeer"] .gtf-rsprite__saddle { left: 35%; top: 44%; width: 18%; height: 13%; }
.gtf-rsprite[data-animal="alpaca"] .gtf-rsprite__saddle { left: 28%; top: 62%; width: 22%; height: 10%; }
.gtf-rsprite[data-animal="grandpa"] .gtf-rsprite__saddle { left: 35%; top: 65%; width: 16%; height: 11%; }
/* The wide grandpa sheets are drawn differently: the body sits further right and higher. */
.gtf-rsprite[data-animal="grandpa"][data-colour="red"] .gtf-rsprite__saddle,
.gtf-rsprite[data-animal="grandpa"][data-colour="default"] .gtf-rsprite__saddle { left: 46%; top: 66%; }

.gtf-rsprite__number {
  position: relative;
  display: block;
  margin-top: 0.35em;
  font-size: 1em;
}

.gtf-rnum {
  --saddle: #ef4444;
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--saddle);
  color: var(--gtf-ink);
  font-family: var(--gtf-mono);
  font-size: 30px;
}

/* ---------- Betting ---------- */

.gtf-rc {
  display: flex;
  flex-direction: column;
  gap: 32px;
  height: 100%;
}

/* Slides sit stacked and off to the right; the controller swipes the current one out to the left and
   the next in from the right. Only the current / leaving states transition, so a finished slide snaps
   back to the right without being seen. */
.gtf-rc__slides {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.gtf-rc__slide {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 72px;
  transform: translateX(110%);
  visibility: hidden;
}

.gtf-rc__slide.is-current,
.gtf-rc__slide.is-leaving {
  visibility: visible;
  transition: transform 0.7s cubic-bezier(0.65, 0, 0.35, 1);
}

.gtf-rc__slide.is-current { transform: none; }
.gtf-rc__slide.is-leaving { transform: translateX(-110%); }

.gtf-rc__stage {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(700px, 42%);
  padding-bottom: 60px; /* room for the counter, which sits outside the sliding slides */
}

.gtf-rc__art {
  flex: 1;
  display: grid;
  place-items: center;
  border-radius: var(--gtf-radius-card);
  background: var(--gtf-rs-horse);
}

.gtf-rc__art--reindeer { background: var(--gtf-rs-reindeer); }
.gtf-rc__art--alpaca { background: var(--gtf-rs-alpaca); }
.gtf-rc__art--grandpa { background: var(--gtf-rs-grandpa); }

.gtf-rc__counter {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 1;
  width: min(700px, 42%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.gtf-rc__count {
  font-size: 30px;
  font-weight: 600;
  color: var(--gtf-text-2);
}

.gtf-rc__dots {
  display: flex;
  gap: 12px;
}

.gtf-rc__dot {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--gtf-surface-4);
}

.gtf-rc__dot.is-current { background: var(--gtf-yellow); }

.gtf-rc__info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.gtf-rc__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
}

.gtf-rc__name {
  font-size: 88px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.gtf-rc__flag { margin-right: 20px; }

.gtf-rc__odds {
  font-family: var(--gtf-mono);
  font-size: 88px;
  color: var(--gtf-yellow);
  white-space: nowrap;
}

.gtf-rc__blurb {
  max-width: 28em;
  margin: 4px 0 14px;
  font-size: 30px;
  line-height: 1.4;
  color: var(--gtf-text-2);
}

.gtf-rc__stat {
  display: grid;
  grid-template-columns: 1fr 100px;
  align-items: center;
  gap: 2px 24px;
  padding: 9px 0;
  border-top: 2px solid var(--gtf-surface-2);
}

.gtf-rc__question {
  font-size: 26px;
  font-weight: 600;
  color: var(--gtf-text-2);
}

.gtf-rc__value {
  grid-row: span 2;
  grid-column: 2;
  font-family: var(--gtf-mono);
  font-size: 44px;
  text-align: right;
}

.gtf-rc__answer {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 20px;
}

.gtf-rc__answer-text {
  flex: none;
  width: min(440px, 45%);
  font-size: 34px;
  font-weight: 800;
  line-height: 1.15;
}

.gtf-rc__meter {
  flex: 1;
  height: 12px;
  border-radius: 6px;
  background: var(--gtf-surface-2);
  overflow: hidden;
}

.gtf-rc__meter-fill {
  display: block;
  height: 100%;
  width: var(--fill, 0%);
  background: var(--gtf-yellow);
}

.gtf-rc__form {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding-top: 16px;
  border-top: 2px solid var(--gtf-surface-2);
}

.gtf-rc__form-label {
  font-size: 26px;
  font-weight: 600;
  color: var(--gtf-text-2);
}

.gtf-rc__form-value {
  font-family: var(--gtf-mono);
  font-size: 40px;
}

.gtf-rc__bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 18px 40px;
  border-radius: var(--gtf-radius-card);
  background: var(--gtf-yellow);
  color: var(--gtf-ink);
}

.gtf-rc__bar-title {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.gtf-rc__bar-line {
  font-size: 36px;
  font-weight: 800;
}

/* ---------- Results ---------- */

.gtf-screen--races [data-controller="ceremony"],
.gtf-screen--races [data-ceremony-target="step"] {
  height: 100%;
}


.gtf-rpod {
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100%;
}

.gtf-rpod--dense { gap: 16px; }

.gtf-rpod__title {
  font-size: 64px;
}

.gtf-rpod__places {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 56px;
  align-items: end;
}

.gtf-rpod__place {
  --tone: var(--gtf-cream);
  padding-top: 20px;
  border-top: 6px solid var(--tone);
  animation: gtf-rs-rise 0.6s ease both;
  animation-delay: calc(0.3s + var(--i, 0) * 0.5s);
}

.gtf-rpod__place--1 { --tone: var(--gtf-yellow); }
.gtf-rpod__place--3 { --tone: var(--gtf-orange); }

.gtf-rpod__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.gtf-rpod__rank {
  font-size: 80px;
  line-height: 1;
  font-weight: 900;
  color: var(--tone);
}

.gtf-rpod__place--1 .gtf-rpod__rank { font-size: 112px; }

.gtf-rpod__name {
  margin: 10px 0 4px;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.gtf-rpod__facts {
  display: flex;
  gap: 28px;
  font-size: 34px;
  color: var(--gtf-text-2);
}

.gtf-rpod__time { color: var(--gtf-cream); }

.gtf-rpod__others {
  padding-top: 24px;
  border-top: 2px solid var(--gtf-surface-2);
}

.gtf-rpod__others-title {
  margin-bottom: 16px;
  font-size: 36px;
  font-weight: 800;
}

.gtf-rpod__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 56px;
}

.gtf-rpod__other {
  display: flex;
  align-items: center;
  gap: 18px;
  animation: gtf-rs-fade 0.6s ease both;
  animation-delay: 1.8s;
}

.gtf-rpod__other-place {
  width: 40px;
  font-size: 30px;
  color: var(--gtf-text-2);
}

.gtf-rpod__other-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.gtf-rpod__other-name {
  font-size: 36px;
  font-weight: 800;
  line-height: 1.1;
}

.gtf-rpod__other-note {
  font-size: 28px;
  color: var(--gtf-text-2);
}

.gtf-rpod__other-note.is-dnf { color: var(--gtf-orange-hi); }

/* ---------- Who backed who ---------- */

.gtf-rbets {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.gtf-rbets__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.gtf-rbets__title { font-size: 64px; }

.gtf-rbets__total {
  font-size: 36px;
  font-weight: 600;
  color: var(--gtf-text-2);
}

.gtf-rbets__rows {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.gtf-rbets__row {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 130px minmax(260px, 520px) 170px minmax(0, 1fr);
  align-items: center;
  gap: 0 24px;
  border-top: 2px solid var(--gtf-surface-2);
  animation: gtf-rs-fade 0.5s ease both;
  animation-delay: calc(0.3s + var(--i, 0) * 0.3s);
}

.gtf-rbets__row--winner { border-top-color: var(--gtf-yellow); }

.gtf-rbets__place {
  font-size: 52px;
  font-weight: 900;
  color: var(--gtf-text-2);
}

.gtf-rbets__row:nth-child(-n + 3) .gtf-rbets__place { color: var(--gtf-cream); }
.gtf-rbets__row--winner .gtf-rbets__place { color: var(--gtf-yellow); }

.gtf-rbets__runner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.gtf-rbets__name {
  font-size: 40px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gtf-rbets__pool {
  font-size: 38px;
  text-align: right;
}

.gtf-rbets__backers {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 28px;
  padding-left: 24px;
  font-size: 30px;
}

.gtf-rbets__backer-name { font-weight: 800; }

.gtf-rbets__stake {
  margin-left: 10px;
  color: var(--gtf-yellow);
}

.gtf-rbets__nobody,
.gtf-rbets__more {
  color: var(--gtf-text-2);
}

/* ---------- Ready (inside a game night) ---------- */

.gtf-rready {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-top: 24px;
}

.gtf-rready__title { font-size: 104px; line-height: 1.05; }

.gtf-rready__sub {
  font-size: 44px;
  line-height: 1.3;
}

.gtf-rready__sub--muted { color: var(--gtf-text-2); }

.gtf-rready .gtf-mslobby__count { margin-top: 24px; }

@keyframes gtf-rs-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes gtf-rs-rise {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gtf-rpod__place,
  .gtf-rpod__other,
  .gtf-rbets__row {
    animation: none;
  }

  .gtf-rc__slide.is-current,
  .gtf-rc__slide.is-leaving {
    transition: none;
  }
}
