/* The jackpot machine: a chrome crest with stars, a chrome cabinet with a warm-dark lane of marquee
   bulbs, a gold bezel, four dark reel drums behind glass, a coin tray and a lever. Every size is a
   share of --g (the glyph size, page.css), so one number scales the whole machine. The base styles
   are the landed frame; the spin and the payout are page.mjs. */

.defs {
  position: absolute;
  width: 0;
  height: 0;
}

.machine {
  position: relative;
  display: grid;
  justify-items: center;
  margin-inline: var(--m-side);
  /* reel geometry */
  --reel-w: calc(var(--g) * var(--reel-k));
  --cell-g: calc(var(--g) * var(--cell-k));
  /* the rows above and below the glyph take what is left of the screen height */
  --peek: clamp(
    calc(var(--g) * var(--peek-min)),
    calc((100svh - var(--m-fixed-y) - var(--g) * (var(--m-k-y) - 2 * var(--peek-min))) / 2),
    calc(var(--g) * var(--peek-max))
  );
  --cell-o: calc(var(--peek) * 1.3);
  --cell-s: calc(var(--reel-w) * 1.02);
  --obj: min(calc(var(--reel-w) * 0.74), calc(var(--g) * 0.36), calc(var(--cell-o) * 0.92));
  --win-h: calc(var(--cell-g) + 2 * var(--peek));
  --radius: calc(var(--g) * 0.12);
  --crest-h: calc(var(--g) * var(--crest-k-h));
}

/* ------------------------------------------------------------------ crest */

/* A chrome half-dome on top of the cabinet: warm rays inside, three gold stars. */
.crest {
  position: relative;
  z-index: 1;
  width: calc(var(--g) * var(--crest-k-w));
  height: var(--crest-h);
  margin-bottom: calc(var(--m-chrome) * -1);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: linear-gradient(
    180deg,
    var(--chrome-1) 0%,
    var(--chrome-2) 18%,
    var(--chrome-4) 46%,
    var(--chrome-2) 64%,
    var(--chrome-3) 100%
  );
  box-shadow: 0 0 calc(var(--g) * 0.3) var(--cabinet-glow);
}
.crest__plate {
  position: absolute;
  inset: var(--m-chrome) var(--m-chrome) 0;
  overflow: clip;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 60% 80% at 50% 100%, var(--reel-glow) 0%, var(--reel-glow-0) 100%),
    repeating-conic-gradient(
      from -90deg at 50% 100%,
      var(--crest-ray) 0deg 5deg,
      var(--crest-ray-0) 5deg 15deg
    ),
    linear-gradient(180deg, var(--lane) 0%, var(--lane-deep) 100%);
}
.crest__star {
  position: absolute;
  bottom: 4%;
  translate: -50% 0;
  filter: drop-shadow(0 0.15rem 0.3rem var(--cast));
}
.crest__star--c {
  left: 50%;
  width: calc(var(--crest-h) * 0.92);
  bottom: 2%;
}
.crest__star--l,
.crest__star--r {
  width: calc(var(--crest-h) * 0.5);
}
.crest__star--l {
  left: 24%;
  rotate: -14deg;
}
.crest__star--r {
  left: 76%;
  rotate: 14deg;
}

/* ------------------------------------------------------------------ cabinet */

.cabinet {
  position: relative;
  z-index: 2;
  padding: var(--m-chrome);
  border-radius: var(--radius);
  background: linear-gradient(
    180deg,
    var(--chrome-1) 0%,
    var(--chrome-2) 10%,
    var(--chrome-3) 38%,
    var(--chrome-1) 50%,
    var(--chrome-3) 66%,
    var(--chrome-4) 100%
  );
  box-shadow:
    0 calc(var(--g) * 0.1) calc(var(--g) * 0.22) calc(var(--g) * -0.04) var(--cabinet-drop),
    0 0 calc(var(--g) * 0.6) var(--cabinet-glow);
}
.lane {
  position: relative;
  padding: var(--m-lane);
  border-radius: calc(var(--radius) - var(--m-chrome));
  background: radial-gradient(ellipse 80% 70% at 50% 0%, var(--lane) 0%, var(--lane-deep) 100%);
  box-shadow:
    inset 0 0 0 1px var(--chrome-5),
    inset 0 0.375rem 0.75rem var(--lane-deep);
}

/* Marquee bulbs: one row on each side of the lane. Each bulb is a socket with a light (::after)
   over it. Rest frame: every other bulb lit. The chase runs round the frame: the bottom and left
   rows are reversed, so the third-by-third delays travel clockwise. */
.bulbs {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: space-between;
  --bulb-d: calc(var(--m-lane) * 0.5);
}
.bulbs--top,
.bulbs--bottom {
  left: 0;
  right: 0;
  height: var(--m-lane);
  padding-inline: calc((var(--m-lane) - var(--bulb-d)) / 2);
}
.bulbs--top {
  top: 0;
}
.bulbs--bottom {
  bottom: 0;
  flex-direction: row-reverse;
}
.bulbs--left,
.bulbs--right {
  top: var(--m-lane);
  bottom: var(--m-lane);
  width: var(--m-lane);
  flex-direction: column;
  justify-content: space-evenly;
}
.bulbs--right {
  right: 0;
}
.bulbs--left {
  left: 0;
  flex-direction: column-reverse;
}
.bulbs :is(i, b) {
  position: relative;
  flex: none;
  width: var(--bulb-d);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--bulb-off) 0%, var(--bulb-socket) 75%);
}
.bulbs :is(i, b)::after {
  content: "";
  position: absolute;
  inset: -130%;
  border-radius: 50%;
  background: radial-gradient(
    closest-side,
    var(--bulb-core) 0 13%,
    var(--bulb) 19% 24%,
    var(--bulb-halo) 32%,
    var(--bulb-halo-0) 100%
  );
}
.bulbs i:nth-child(even)::after {
  opacity: 0.22;
}
@media (prefers-reduced-motion: no-preference) {
  .bulbs i::after {
    animation: chase var(--t-chase) linear infinite;
  }
  .bulbs i:nth-child(3n + 2)::after {
    animation-delay: calc(var(--t-chase) / -3);
  }
  .bulbs i:nth-child(3n + 1)::after {
    animation-delay: calc(var(--t-chase) / -1.5);
  }
  .machine[data-mode="spin"] .bulbs i::after {
    animation-duration: var(--t-chase-fast);
  }
  .machine[data-mode="spin"] .bulbs i:nth-child(3n + 2)::after {
    animation-delay: calc(var(--t-chase-fast) / -3);
  }
  .machine[data-mode="spin"] .bulbs i:nth-child(3n + 1)::after {
    animation-delay: calc(var(--t-chase-fast) / -1.5);
  }
  .machine[data-mode="win"] .bulbs i::after {
    animation: blink 0.32s linear infinite;
  }

  /* With JS the same chase runs on rows (page.mjs, buildGlow): each side gets one row of lights
     per phase over its sockets, and the row blinks, so 12 rows animate instead of 48 lights. The
     row lights are <b>, so the i rules above (and a data-mode change) never touch them. */
  .machine[data-glow] .bulbs:not(.bulbs--glow) i::after {
    content: none;
  }
  .bulbs.bulbs--glow b {
    background: none;
  }
  .bulbs.bulbs--glow b:not(.on)::after {
    content: none;
  }
  .bulbs.bulbs--glow {
    animation: chase var(--t-chase) linear infinite;
  }
  .bulbs.bulbs--p2 {
    animation-delay: calc(var(--t-chase) / -3);
  }
  .bulbs.bulbs--p1 {
    animation-delay: calc(var(--t-chase) / -1.5);
  }
  .machine[data-mode="spin"] .bulbs.bulbs--glow {
    animation-duration: var(--t-chase-fast);
  }
  .machine[data-mode="spin"] .bulbs.bulbs--p2 {
    animation-delay: calc(var(--t-chase-fast) / -3);
  }
  .machine[data-mode="spin"] .bulbs.bulbs--p1 {
    animation-delay: calc(var(--t-chase-fast) / -1.5);
  }
  .machine[data-mode="win"] .bulbs.bulbs--glow {
    animation: blink 0.32s linear infinite;
  }
}
@keyframes chase {
  0%,
  30% {
    opacity: 1;
  }
  42%,
  100% {
    opacity: 0.2;
  }
}
@keyframes blink {
  0%,
  48% {
    opacity: 1;
  }
  52%,
  100% {
    opacity: 0.15;
  }
}

/* ------------------------------------------------------------------ bezel and reels */

.bezel {
  position: relative;
  padding: var(--m-rim);
  border-radius: calc(var(--radius) * 0.55);
  background: linear-gradient(
    160deg,
    var(--gold-1) 0%,
    var(--gold-2) 16%,
    var(--gold-3) 42%,
    var(--gold-1) 56%,
    var(--gold-3) 72%,
    var(--gold-4) 100%
  );
  box-shadow:
    0 0 0 1px var(--gold-5),
    0 0.25rem 0.75rem var(--cabinet-drop);
}
/* Payline arrows in the lane, pointing at the glyph row. */
.pay {
  position: absolute;
  top: 50%;
  z-index: 1;
  width: calc(var(--m-lane) * 0.62);
  height: calc(var(--m-lane) * 0.9);
  translate: 0 -50%;
  background: linear-gradient(180deg, var(--gold-1), var(--gold-2) 40%, var(--gold-4));
}
.pay--l {
  right: calc(100% + var(--m-lane) * 0.12);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.pay--r {
  left: calc(100% + var(--m-lane) * 0.12);
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
}
/* The window: four drums with dark metal between them. */
.window {
  position: relative;
  display: flex;
  gap: var(--reel-gap);
  height: var(--win-h);
  overflow: clip;
  border-radius: calc(var(--radius) * 0.4);
  background: linear-gradient(90deg, var(--chrome-5) 0%, var(--chrome-4) 50%, var(--chrome-5) 100%);
}
.reel {
  position: relative;
  flex: none;
  width: var(--reel-w);
  overflow: clip;
  background:
    radial-gradient(
      ellipse 110% calc(var(--cell-g) * 0.6) at 50% 50%,
      var(--reel-glow) 0%,
      var(--reel-glow-0) 100%
    ),
    linear-gradient(180deg, var(--reel-dark) 0%, var(--reel-mid) 50%, var(--reel-dark) 100%);
}
/* drum shading: the rows above and below turn away into the dark */
.reel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    180deg,
    var(--drum-shade) 0%,
    var(--drum-shade-mid) 6%,
    var(--drum-shade-0) 16%,
    var(--drum-shade-0) 84%,
    var(--drum-shade-mid) 94%,
    var(--drum-shade) 100%
  );
  pointer-events: none;
}
.reel__rest,
.reel__spin {
  position: absolute;
  left: 0;
  right: 0;
}
.reel__rest {
  top: calc(var(--peek) - var(--cell-o));
  display: grid;
  grid-template-rows: var(--cell-o) var(--cell-g) var(--cell-o);
}
/* the spinning strip (page.mjs): blurred objects, rest hidden */
.reel__spin {
  top: 0;
  opacity: 0;
}
.cell {
  display: grid;
  place-items: center;
}
.cell--spin {
  height: var(--cell-s);
}
.cell img {
  width: var(--obj);
  filter: saturate(1.15) drop-shadow(0 calc(var(--obj) * 0.06) calc(var(--obj) * 0.08) var(--cast));
}
.cell--spin img {
  scale: 1 1.25;
  filter: url("#vblur");
}

/* The glyph: the 3D numeral of the main page (flat yellow face, lit top, stacked amber side). */
.cell--glyph {
  font-size: var(--g);
  font-weight: 900;
  line-height: 0.8;
  white-space: nowrap;
}
.g {
  grid-area: 1 / 1;
  color: var(--accent);
  text-shadow: var(--extrude);
  text-box: trim-both cap alphabetic;
  translate: -0.03em 0;
}
.g--hi {
  color: transparent;
  text-shadow: none;
  background: linear-gradient(180deg, var(--num-hi) 4%, var(--num-hi-0) 46%);
  background-clip: text;
}
.g--pct {
  font-size: 0.64em;
  translate: -0.04em 0;
}

/* Win row frame: two bright lines round the glyph row, flashed by the payout. */
.payline {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - var(--cell-g) / 2);
  z-index: 3;
  height: var(--cell-g);
  border-block: max(2px, calc(var(--g) * 0.012)) solid var(--winline);
  background: radial-gradient(ellipse 60% 60% at 50% 50%, var(--reel-glow), var(--reel-glow-0));
  opacity: 0;
  pointer-events: none;
}

/* Glass over the reels: a cold sheen from the top left, a curved reflection, depth at the rim,
   and a glint that crosses it now and then. */
.glass {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: clip;
  border-radius: inherit;
  background:
    linear-gradient(168deg, var(--glass-hi-soft) 0%, var(--glass-0) 26%),
    linear-gradient(0deg, var(--glass-hi-soft) 0%, var(--glass-0) 8%);
  box-shadow:
    inset 0 calc(var(--g) * 0.05) calc(var(--g) * 0.1) var(--glass-in),
    inset 0 calc(var(--g) * -0.04) calc(var(--g) * 0.08) var(--glass-in);
  pointer-events: none;
}
.glass::before {
  content: "";
  position: absolute;
  left: 3%;
  right: 3%;
  top: 1%;
  height: 5%;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--glass-hi) 0%, var(--glass-0) 100%);
}
.glass__glint {
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: 0;
  width: 16%;
  background: linear-gradient(90deg, var(--glass-0), var(--glass-glint), var(--glass-0));
  transform: translateX(-130%) skewX(-16deg);
}
@media (prefers-reduced-motion: no-preference) {
  html:not([data-intro]) .glass__glint {
    animation: sweep var(--t-sweep) ease-in-out 1.2s infinite;
  }
}
@keyframes sweep {
  0% {
    transform: translateX(-130%) skewX(-16deg);
  }
  24%,
  100% {
    transform: translateX(760%) skewX(-16deg);
  }
}

/* ------------------------------------------------------------------ tray and lever */

.tray {
  position: relative;
  z-index: 1;
  width: 86%;
  height: calc(var(--g) * var(--tray-k));
  border-radius: 0 0 calc(var(--radius) * 0.8) calc(var(--radius) * 0.8);
  background: linear-gradient(
    180deg,
    var(--chrome-4) 0%,
    var(--chrome-2) 30%,
    var(--chrome-1) 45%,
    var(--chrome-3) 100%
  );
  box-shadow: 0 calc(var(--g) * 0.06) calc(var(--g) * 0.12) var(--cabinet-drop);
}
.tray__slot {
  position: absolute;
  left: 30%;
  right: 30%;
  top: 34%;
  height: 26%;
  border-radius: 999px;
  background: var(--lane-deep);
  box-shadow: inset 0 2px 3px var(--black);
}

/* The lever on the right side of the cabinet: a chrome hub, a rod, a glossy gold knob. page.mjs
   pulls it by flipping the arm through scaleY around the hub (it swings toward the viewer). */
.lever {
  position: absolute;
  z-index: 3;
  top: calc(var(--crest-h) + var(--m-frame) + var(--win-h) * 0.5);
  left: calc(100% - var(--m-chrome));
  width: var(--hub-w);
  height: calc(var(--hub-w) * 1.9);
  translate: 0 -50%;
  --hub-w: max(0.75rem, calc(var(--g) * 0.1));
  --rod-w: max(0.3125rem, calc(var(--g) * 0.04));
  --knob: max(1.25rem, calc(var(--g) * 0.2));
  /* how far page.mjs swings the arm (scaleY at the bottom of the pull) */
  --pull: -0.75;
}
.lever__hub {
  position: absolute;
  inset: 0;
  border-radius: 0 calc(var(--hub-w) * 0.5) calc(var(--hub-w) * 0.5) 0;
  background: linear-gradient(
    90deg,
    var(--chrome-4) 0%,
    var(--chrome-1) 35%,
    var(--chrome-2) 60%,
    var(--chrome-4) 100%
  );
  box-shadow: 0 0.25rem 0.5rem var(--cabinet-drop);
}
.lever__arm {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: var(--rod-w);
  height: calc(var(--g) * 0.72);
  translate: -50% 0;
  transform-origin: 50% 100%;
}
.lever__rod {
  position: absolute;
  inset: 0;
  border-radius: var(--rod-w);
  background: linear-gradient(
    90deg,
    var(--chrome-4),
    var(--chrome-1) 40%,
    var(--chrome-2) 60%,
    var(--chrome-4)
  );
}
.lever__knob {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--knob);
  aspect-ratio: 1;
  translate: -50% -60%;
  border-radius: 50%;
  background: radial-gradient(
    circle at 34% 30%,
    var(--knob-hi) 0 9%,
    var(--gold-2) 28%,
    var(--gold-3) 66%,
    var(--gold-4) 100%
  );
  box-shadow: 0 0.2rem 0.5rem var(--cabinet-drop);
}

/* Warm light of the machine on the floor under it. */
.machine::before {
  content: "";
  position: absolute;
  left: -25%;
  right: -25%;
  bottom: calc(var(--g) * -0.2);
  height: calc(var(--g) * 0.7);
  background: radial-gradient(closest-side, var(--cabinet-glow), var(--reel-glow-0));
  pointer-events: none;
}

/* Two stacks of coins at the foot of the cabinet, in front of it. Coins sit flat (--sy) and
   stack upward; positions are in the stack box. */
.pile {
  position: absolute;
  z-index: 3;
  bottom: calc(var(--g) * -0.06);
  width: calc(var(--g) * 0.5);
  height: calc(var(--g) * 0.42);
  pointer-events: none;
}
.pile--l {
  left: calc(var(--g) * -0.12);
}
.pile--r {
  right: calc(var(--g) * -0.1);
  scale: -1 1;
}
.pile .coin {
  --cs: calc(var(--g) * 0.22);
  --sy: 0.42;
}
.pile .p1 {
  --x: 30%;
  --y: 88%;
}
.pile .p2 {
  --x: 31%;
  --y: 77%;
}
.pile .p3 {
  --x: 29%;
  --y: 66%;
}
.pile .p4 {
  --x: 31%;
  --y: 55%;
}
.pile .p5 {
  --x: 66%;
  --y: 90%;
  --r: -8deg;
}
.pile .p6 {
  --x: 70%;
  --y: 80%;
  --sy: 0.95;
  --r: 24deg;
}

/* ------------------------------------------------------------------ loose gold */

.deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.deco--far {
  z-index: 1;
}
.deco--near {
  z-index: 4;
}
/* A coin: gold disc with a raised rim, lit from the top left, a thick edge below (box-shadow),
   squashed by --sy into perspective and turned by --r. Far ones are small and soft, near ones big
   and out of focus. */
.coin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--cs);
  aspect-ratio: 1;
  translate: -50% -50%;
  rotate: var(--r, 0deg);
  scale: 1 var(--sy, 0.8);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, var(--coin-hi) 0 6%, var(--coin-hi-0) 26%),
    radial-gradient(
      closest-side,
      var(--gold-2) 0 62%,
      var(--gold-4) 65% 68%,
      var(--gold-1) 71% 76%,
      var(--gold-3) 86%,
      var(--gold-4) 100%
    );
  box-shadow:
    0 calc(var(--cs) * 0.05) 0 var(--gold-4),
    0 calc(var(--cs) * 0.1) 0 var(--gold-5),
    0 calc(var(--cs) * 0.18) calc(var(--cs) * 0.16) var(--cast);
  filter: blur(var(--b, 0px));
}
.coin__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--cs) * 0.52);
  font-weight: 900;
  line-height: 1;
  color: var(--gold-3);
  text-shadow:
    0 -0.03em 0 var(--gold-4),
    0 0.04em 0 var(--gold-1);
}
.twinkle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--cs);
  translate: -50% -50%;
  rotate: var(--r, 0deg);
  filter: blur(var(--b, 0px)) drop-shadow(0 0 0.5rem var(--bulb-halo));
}
@media (prefers-reduced-motion: no-preference) {
  html:not([data-intro]) .deco > :is(.coin, .twinkle) {
    animation: float var(--t-coin) ease-in-out calc(var(--at, 0) * -1s) infinite alternate;
  }
}
@keyframes float {
  to {
    transform: translateY(calc(var(--cs) * -0.14)) rotate(calc(var(--spin, 8) * 1deg));
  }
}

/* Portrait: loose gold peeks from behind the machine and fills the corners round the button. */
.k1 {
  --x: 9%;
  --y: 6%;
  --cs: clamp(2rem, 9vmin, 3.5rem);
  --r: -24deg;
  --b: 1.5px;
  --at: 0.6;
}
.k2 {
  --x: 94%;
  --y: 36%;
  --cs: clamp(2.25rem, 10vmin, 4rem);
  --r: 30deg;
  --sy: 0.6;
  --at: 1.9;
}
.k3 {
  --x: 6%;
  --y: 58%;
  --cs: clamp(1.75rem, 8vmin, 3rem);
  --r: 12deg;
  --b: 1px;
  --at: 2.8;
}
.k4 {
  --x: 4%;
  --y: 90%;
  --cs: clamp(4rem, 20vmin, 8rem);
  --r: 20deg;
  --b: 3px;
  --sy: 0.7;
  --at: 1.2;
}
.k5 {
  --x: 97%;
  --y: 70%;
  --cs: clamp(3rem, 14vmin, 6rem);
  --r: -32deg;
  --b: 2.5px;
  --at: 0.2;
}
.k6 {
  --x: 90%;
  --y: 4%;
  --cs: clamp(2.5rem, 12vmin, 5rem);
  --r: 18deg;
  --b: 2px;
  --sy: 0.62;
  --at: 2.2;
}
.t1 {
  --x: 14%;
  --y: 16%;
  --cs: clamp(1.75rem, 7vmin, 3rem);
  --r: -12deg;
  --at: 1;
  --spin: 18;
}
.t2 {
  --x: 85%;
  --y: 14%;
  --cs: clamp(1.25rem, 5vmin, 2.25rem);
  --r: 16deg;
  --b: 1px;
  --at: 2.5;
  --spin: -16;
}
.t3 {
  --x: 93%;
  --y: 52%;
  --cs: clamp(1.25rem, 5vmin, 2.5rem);
  --r: -20deg;
  --b: 1.5px;
  --at: 1.7;
  --spin: 20;
}
.t4 {
  --x: 8%;
  --y: 74%;
  --cs: clamp(1rem, 4.5vmin, 2rem);
  --r: 10deg;
  --b: 1px;
  --at: 0.4;
  --spin: -22;
}

/* Landscape: the gold spreads over the sides of the stage. */
@media (min-aspect-ratio: 1 / 1) {
  .k1 {
    --x: 20%;
    --y: 18%;
  }
  .k2 {
    --x: 81%;
    --y: 58%;
  }
  .k3 {
    --x: 13%;
    --y: 56%;
  }
  .k4 {
    --x: 6%;
    --y: 88%;
  }
  .k5 {
    --x: 94%;
    --y: 26%;
  }
  .k6 {
    --x: 88%;
    --y: 92%;
  }
  .t1 {
    --x: 16%;
    --y: 34%;
  }
  .t2 {
    --x: 79%;
    --y: 12%;
  }
  .t3 {
    --x: 85%;
    --y: 44%;
  }
  .t4 {
    --x: 21%;
    --y: 72%;
  }
}

/* Desktop: the sport objects take the side strips (--side, page.css), the loose gold moves to
   the corners round them. */
.flanks {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.flanks--near {
  z-index: auto;
}
.flank {
  position: absolute;
  left: var(--fx);
  top: var(--fy);
  width: var(--fs);
  translate: -50% -50%;
}
.flank.fl-r {
  left: calc(100% - var(--fx));
}
.flank img {
  width: 100%;
  rotate: var(--fr, 0deg);
  filter: drop-shadow(0 calc(var(--fs) * 0.08) calc(var(--fs) * 0.1) var(--cast))
    blur(var(--fb, 0px));
}
.fl-near {
  --fx: calc(var(--side) * 0.62);
  --fy: 62%;
  --fs: min(calc(var(--g) * 0.56), calc(var(--side) * 0.9));
}
.fl-near.fl-l {
  --fy: 48%;
  --fr: -10deg;
}
.fl-near.fl-r {
  --fy: 56%;
  --fr: 14deg;
}
.fl-mid {
  --fx: calc(var(--side) * 0.36);
  --fy: 25%;
  --fs: min(calc(var(--g) * 0.36), calc(var(--side) * 0.58));
  --fb: 2.5px;
}
.fl-mid.fl-l {
  --fr: -24deg;
}
.fl-mid.fl-r {
  --fy: 23%;
  --fr: -18deg;
}
.fl-far {
  --fx: calc(var(--side) * 0.2);
  --fy: 86%;
  --fs: min(calc(var(--g) * 0.24), calc(var(--side) * 0.4));
  --fb: 5px;
}
.fl-far.fl-r {
  --fy: 83%;
}
@media (prefers-reduced-motion: no-preference) {
  html:not([data-intro]) .flank img {
    animation: hover var(--t-hover, 5.2s) ease-in-out var(--fa, 0s) infinite alternate;
  }
  .fl-r {
    --t-hover: 6.1s;
    --fa: -2.3s;
  }
  .fl-mid {
    --fa: -1.1s;
  }
  .fl-far {
    --fa: -3.4s;
  }
}
@keyframes hover {
  to {
    transform: translateY(-6%) rotate(5deg);
  }
}
@media (min-width: 64rem) and (min-aspect-ratio: 1 / 1) {
  .flanks {
    display: block;
  }
  .k1 {
    --x: calc(var(--side) * 0.78);
    --y: 9%;
  }
  .k2 {
    --x: calc(100% - var(--side) * 0.18);
    --y: 45%;
  }
  .k3 {
    --x: calc(var(--side) * 0.14);
    --y: 47%;
  }
  .k4 {
    --x: 3%;
    --y: 97%;
  }
  .k5 {
    --x: calc(100% - var(--side) * 0.3);
    --y: 7%;
  }
  .k6 {
    --x: 97%;
    --y: 98%;
  }
  .t1 {
    --x: calc(var(--side) * 0.88);
    --y: 40%;
  }
  .t2 {
    --x: calc(100% - var(--side) * 0.1);
    --y: 30%;
  }
  .t3 {
    --x: calc(100% - var(--side) * 0.86);
    --y: 36%;
  }
  .t4 {
    --x: calc(var(--side) * 0.1);
    --y: 14%;
  }
}

/* Narrow portrait: no room beside the cabinet, so the lever stands on its top right corner next to
   the crest, and the pull swings it toward the viewer (foreshortened), not down over the reels. */
@media (max-aspect-ratio: 1 / 1) and (max-width: 47.99rem) {
  .lever {
    top: var(--crest-h);
    left: auto;
    right: calc(var(--g) * 0.16);
    height: calc(var(--hub-w) * 0.9);
    translate: 0 -40%;
    --pull: 0.22;
  }
  .lever__hub {
    border-radius: calc(var(--hub-w) * 0.5) calc(var(--hub-w) * 0.5) 0 0;
  }
  .lever__arm {
    height: calc(var(--crest-h) * 1.5);
  }
}

/* The payout: coins, confetti and stars made by page.mjs fly in front of everything. */
.spray {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.spray > * {
  position: absolute;
  left: 0;
  top: 0;
}
.bit {
  width: var(--w);
  height: var(--h);
  translate: -50% -50%;
  background: var(--c);
}
/* flying coins: a flat edge instead of the stacked shadow, so a flip never repaints a blur */
.spray .coin {
  left: 0;
  top: 0;
  box-shadow: none;
  border-bottom: calc(var(--cs) * 0.07) solid var(--gold-4);
  /* the loose-gold blur is 0 here; a filter of 0 still made every coin an offscreen pass */
  filter: none;
}
/* Coins and confetti flip through scaleX/scaleY. Without the hint the browser re-rasterised
   every piece on every frame of the flip (about 60 pieces, most of the GPU time of the payout);
   with it each piece is drawn once at full size and the flip only scales its layer. The hint goes
   on when the payout starts (page.mjs adds .is-live): before that the pieces wait hidden and need
   no layers of their own. */
.spray.is-live :is(.coin, .bit) {
  will-change: transform;
}
.spray .twinkle {
  left: 0;
  top: 0;
  filter: none;
}

/* While the spin runs, the strips move on their own layers. */
[data-intro="running"] :is(.reel__spin, .reel__rest, .lever__arm) {
  will-change: transform, opacity;
}
