:root {
  /* Keep wide props clear of the wordmark and the viewport's left edge. */
  --mascot-left-room: calc(var(--duck-size) * .355);
  --mascot-right-room: calc(var(--duck-size) * .312 + 2px);
}
.brand-header .wordmark {
  margin-left: max(0px, calc(var(--mascot-left-room) - var(--gutter)));
  column-gap: max(clamp(.25rem, .8vw, .7rem), var(--mascot-right-room));
}
.wordmark .duck-mascot {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: auto;
  min-width: 44px;
  min-height: 44px;
  overflow: visible;
  margin: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 35%;
  box-shadow: none;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.wordmark .duck-mascot:focus-visible {
  outline: 3px solid #ffe078;
  outline-offset: 2px;
}
.duck-plumage {
  position: relative;
  display: grid;
  width: var(--duck-size);
  height: var(--duck-size);
  transform-origin: 50% 75%;
}
.duck-plumage > .wake-duck, .mascot-frame { width: 100%; height: 100%; }
.mascot-frame { position: relative; display: block; pointer-events: none; }
.duck-mascot .mascot-frame { transform: rotate(-6deg); }
/* The frame is the original duck's coordinate system. Hats and props can
   paint outside it without contributing to button size or hit testing. */
.duck-mascot .mascot-frame img, .duck-bonus-ferry .mascot-frame img {
  display: block;
  position: absolute;
  top: calc(100% * var(--mascot-y, 0));
  left: calc(100% * var(--mascot-x, 0));
  width: calc(100% * var(--mascot-scale, 1));
  height: calc(100% * var(--mascot-scale, 1));
  max-width: none;
  max-height: none;
  object-fit: contain;
  transform: none;
  pointer-events: none;
}
.duck-mascot img { display: block; user-select: none; -webkit-user-drag: none; }
.duck-spray { position: absolute; inset: 0; pointer-events: none; }
.duck-spray i { display: none; }

@media (prefers-reduced-motion: no-preference) {
  :root {
    /* The CRT and teacup swing furthest sideways during the feather shake. */
    --mascot-left-room: calc(var(--duck-size) * .445);
    --mascot-right-room: calc(var(--duck-size) * .365 + 2px);
  }
  .mascot-crossfade > .wake-duck,
  .mascot-crossfade [data-account-mascot] {
    animation: mascot-appear 420ms ease-in-out both;
  }
  .mascot-crossfade::after {
    content: "";
    position: absolute;
    left: calc(100% * var(--previous-x, 0));
    top: calc(100% * var(--previous-y, 0));
    width: calc(100% * var(--previous-scale, 1));
    height: calc(100% * var(--previous-scale, 1));
    background: var(--previous-mascot) center / contain no-repeat;
    transform: rotate(-6deg);
    transform-origin: calc((.5 - var(--previous-x, 0)) * 100% / var(--previous-scale, 1))
                      calc((.5 - var(--previous-y, 0)) * 100% / var(--previous-scale, 1));
    pointer-events: none;
    animation: mascot-appear 420ms ease-in-out reverse both;
  }
  .duck-mascot.is-shaking .duck-plumage {
    animation: duck-feather-shake 680ms ease-in-out;
  }
  .duck-mascot.is-shaking .duck-spray i {
    position: absolute;
    display: block;
    left: var(--from);
    top: 42%;
    width: clamp(3px, .10em, 6px);
    height: clamp(5px, .16em, 9px);
    border-radius: 80% 20% 65% 35%;
    background: #c6f0e5;
    opacity: 0;
    animation: duck-water-drop 405ms var(--delay) ease-out both;
  }
  .duck-spray i:nth-child(1) { --from: 30%; --x: -.58em; --y: -.47em; --tilt: -60deg; --delay: 105ms; }
  .duck-spray i:nth-child(2) { --from: 46%; --x: -.25em; --y: -.67em; --tilt: -35deg; --delay: 125ms; }
  .duck-spray i:nth-child(3) { --from: 68%; --x: .48em; --y: -.57em; --tilt: 25deg; --delay: 170ms; }
  .duck-spray i:nth-child(4) { --from: 72%; --x: .68em; --y: -.29em; --tilt: 50deg; --delay: 200ms; }
  .duck-spray i:nth-child(5) { --from: 32%; --x: -.55em; --y: -.21em; --tilt: -78deg; --delay: 230ms; }
  .duck-spray i:nth-child(6) { --from: 61%; --x: .24em; --y: -.62em; --tilt: 8deg; --delay: 245ms; }
}
@keyframes mascot-appear { from { opacity: 0; } to { opacity: 1; } }
@keyframes duck-feather-shake {
  0%, 100% { transform: none; }
  14% { transform: translateY(3%) rotate(-7deg) scale(1.06,.90); }
  25% { transform: translateY(-5%) rotate(13deg) scale(.96,1.04); }
  36% { transform: translateY(-3%) rotate(-13deg); }
  46% { transform: translateY(-2%) rotate(10deg); }
  55% { transform: rotate(-8deg); }
  63% { transform: rotate(6deg); }
  73% { transform: translateY(2%) rotate(-3deg) scale(1.03,.97); }
  86% { transform: rotate(1.5deg); }
}
@keyframes duck-water-drop {
  0% { opacity: 0; transform: scale(.35) rotate(var(--tilt)); }
  12% { opacity: .95; }
  64% { opacity: .9; transform: translate(calc(var(--x) * .76), var(--y)) rotate(var(--tilt)); }
  100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + .26em)) rotate(var(--tilt)) scale(.62); }
}

.duck-bonus-flight {
  --coin-size: clamp(20px, 6vw, 28px);
  position: absolute;
  z-index: 2;
  width: var(--coin-size);
  height: var(--coin-size);
  margin-left: calc(var(--coin-size) * -.5);
  margin-top: calc(var(--coin-size) * -.5);
  pointer-events: none;
}
.duck-bonus-flight .coin-spin {
  animation: duck-bonus-coin-turn 740ms ease-in-out both;
}
.wallet-balance strong { transform-origin: right center; }
.balance-digits[data-duck-display] {
  display: inline-block;
  position: relative;
  color: transparent;
}
.balance-digits[data-duck-display]::after {
  content: attr(data-duck-display);
  content: attr(data-duck-display) / "";
  position: absolute;
  top: 0;
  right: 0;
  white-space: nowrap;
  color: #ffe078;
  pointer-events: none;
}
@keyframes duck-bonus-coin-turn {
  0% { transform: perspective(260px) rotateY(-28deg) rotateZ(-16deg) scale(.43); }
  17% { transform: perspective(260px) rotateY(28deg) rotateZ(-6deg) scale(1.05); }
  55% { transform: perspective(260px) rotateY(193deg) rotateZ(9deg); }
  86% { transform: perspective(260px) rotateY(322deg) rotateZ(-5deg); }
  100% { transform: perspective(260px) rotateY(360deg) scale(.32); }
}
@media (prefers-reduced-motion: reduce) {
  .duck-bonus-flight { display: none; }
}

/* The swimmer and its cargo share the header's coordinate system as it scrolls. */
.duck-bonus-swimmer { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .duck-bonus-away .duck-plumage, .duck-bonus-away .duck-spray { visibility: hidden; }
  .duck-bonus-swimmer {
    position: absolute;
    z-index: 2;
    display: block;
    pointer-events: none;
    user-select: none;
    animation: duck-bonus-round-trip 2200ms linear both;
  }
  .duck-bonus-ferry { position: absolute; inset: 0; animation: duck-bonus-turn 2200ms linear both; }
  .duck-bonus-ferry .mascot-frame {
    animation: duck-bonus-paddle 260ms ease-in-out infinite alternate;
  }
  .duck-bonus-ferry::before, .duck-bonus-ferry::after {
    content: "";
    position: absolute;
    z-index: -1;
    bottom: 12%;
    left: -14%;
    width: 75%;
    height: 11%;
    border-bottom: 2px solid #a8dfd0;
    border-radius: 50%;
    transform: rotate(4deg);
  }
  .duck-bonus-ferry::after { left: -24%; bottom: 8%; width: 45%; border-color: #6eaa9b; }
  .duck-bonus-loot {
    --coin-size: clamp(12px, calc(var(--duck-size) * .21), 21px);
    position: absolute;
    top: 38%;
    left: 46%;
    animation: duck-bonus-stow 2200ms linear both;
  }
  .duck-bonus-pickup {
    position: absolute;
    left: calc(var(--slot) * var(--coin-size) * .55);
    width: var(--coin-size);
    height: var(--coin-size);
    animation: duck-bonus-scoop 260ms calc(740ms + var(--slot) * 75ms) cubic-bezier(.24,.67,.31,1) both;
  }
  .duck-bonus-pickup:nth-child(even) { top: calc(var(--coin-size) * -.34); }
  .duck-bonus-pickup .coin-spin {
    animation: none;
    transform: rotateY(-22deg) rotateZ(calc((var(--slot) - 2) * 8deg));
  }
}
@keyframes duck-bonus-round-trip {
  0% { transform: translate(0,0); animation-timing-function: cubic-bezier(.42,.12,.2,1); }
  34%, 57% { transform: translate(var(--dock-x),var(--dock-y)); animation-timing-function: cubic-bezier(.4,.06,.23,1); }
  95%, 100% { transform: translate(0,0); }
}
@keyframes duck-bonus-turn {
  0%, 100% { transform: scale(1); }
  11%, 43% { transform: scale(.7); }
  48% { transform: translateY(3%) rotate(8deg) scale(.73,.63); }
  56%, 89% { transform: scale(-.7,.7); }
  93% { transform: scale(-.83,.83); }
}
@keyframes duck-bonus-paddle {
  from { transform: translateY(1%) rotate(-7deg); }
  to { transform: translateY(-3%) rotate(-2deg); }
}
@keyframes duck-bonus-scoop {
  from { opacity: 0; transform: translate(65%,20%) scale(.45); }
  48% { opacity: 1; transform: translate(30%,-80%) scale(1.1); }
  to { opacity: 1; transform: none; }
}
@keyframes duck-bonus-stow {
  0%, 91% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translate(-8px,4px) scale(.6); }
}
