/* THE CARD. One printed plastic gift card, used at three sizes: hero / deck / mini (past).
   Every measure inside a card is in cqw of the card body, so it scales like a printed thing.
   Layers, bottom to top:  ground shadow (stays on the ground) -> white core edge -> the plate (print, foil, ink, stamps, gloss, grain). */

.card {
  --thick: 6px;                 /* how thick the plastic is */
  --sh: 10px;                   /* hard ground shadow beyond the edge */
  --r: 5.6cqw;                  /* corner radius */
  --cut: 0px;                   /* the folded corner (hero only) */
  --spot: var(--orange);        /* the card's spot ink */
  --stock: var(--cream);
  --foil: linear-gradient(180deg, #E9ECEE 0 11%, #8F9498 11% 16%, #7FE0B0 16% 30%, #F2D675 30% 39%, #E9ECEE 39% 46%, #FF9A8B 46% 60%, #C9CCCF 60% 74%, #39B8A6 74% 83%, #F4EFE2 83% 90%, #8F9498 90% 100%);
  --guilloche: var(--tex-guilloche);
  --rosette: var(--tex-rosette);
  position: relative;
  display: block;
  padding: 0 calc(var(--thick) + var(--sh)) calc(var(--thick) + var(--sh)) 0; /* room for the edge and the shadow */
  color: var(--ink);
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}
.card--gold {
  --spot: var(--gold-1);
  --stock: #F6EDCF;
  --foil: linear-gradient(180deg, var(--gold-1) 0 16%, var(--gold-2) 16% 30%, #FFF3B8 30% 36%, var(--gold-2) 36% 44%, var(--gold-1) 44% 62%, var(--gold-3) 62% 72%, var(--gold-1) 72% 86%, var(--gold-2) 86% 100%);
  --guilloche: var(--tex-guilloche-gold);
  --rosette: var(--tex-rosette-gold);
}

/* ── sizes ──────────────────────────────────────────────────────────────────── */
.card--hero {
  container: slot / inline-size;
  width: 100%;
  min-width: 272px;
  --cut: 15.5cqw;
}
.card--hero .card__rig {
  width: min(100%, var(--card-hero-port-max));
  aspect-ratio: var(--card-hero-port-ratio);
  margin-inline: auto;
}
.card--deck {
  --thick: 3px;
  --sh: 6px;
  --r: 4cqw;
  width: 100%;
  max-width: calc(var(--card-deck-max) + 9px);
  transform: rotate(var(--rot, 0deg));
}
.card--deck .card__rig {
  aspect-ratio: var(--card-deck-ratio);
}

/* ── the stack of layers ────────────────────────────────────────────────────── */
.card__rig {
  position: relative;
  container: card / inline-size;
  width: 100%;
  perspective: 1400px;
  /* the outline of the card: three round corners and the folded one. It lives HERE, on the rig,
     because a custom property takes its var()s from the element it is set on, and the rig is where
     the landscape card changes --r and --cut. */
  --shape: polygon(
    0 var(--r),
    calc(var(--r) * 0.0761) calc(var(--r) * 0.6173),
    calc(var(--r) * 0.2929) calc(var(--r) * 0.2929),
    calc(var(--r) * 0.6173) calc(var(--r) * 0.0761),
    var(--r) 0,
    calc(100% - var(--r)) 0,
    calc(100% - var(--r) * 0.6173) calc(var(--r) * 0.0761),
    calc(100% - var(--r) * 0.2929) calc(var(--r) * 0.2929),
    calc(100% - var(--r) * 0.0761) calc(var(--r) * 0.6173),
    100% var(--r),
    100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%,
    var(--r) 100%,
    calc(var(--r) * 0.6173) calc(100% - var(--r) * 0.0761),
    calc(var(--r) * 0.2929) calc(100% - var(--r) * 0.2929),
    calc(var(--r) * 0.0761) calc(100% - var(--r) * 0.6173),
    0 calc(100% - var(--r))
  );
}
.card__shadow,
.card__tilt,
.card__flip,
.card__side,
.card__core,
.card__plate {
  position: absolute;
  inset: 0;
}
.card__shadow {
  border-radius: var(--r);
  background: var(--ink);
  transform: translate(calc(var(--thick) + var(--sh)), calc(var(--thick) + var(--sh)));
}
.card__tilt {
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
}
.card__flip {
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.5, 0, 0.2, 1.22);
}
.card.is-flipped .card__flip {
  transform: rotateY(180deg);
}
.card__side {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.card__side--rear {
  transform: rotateY(180deg);
}
/* the edge: a white plastic core with a darker bottom laminate */
.card__side::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r);
  background: #A9A28F;
  transform: translate(var(--thick), var(--thick));
}
.card__core {
  border-radius: var(--r);
  background: var(--core);
  transform: translate(calc(var(--thick) - 1.5px), calc(var(--thick) - 1.5px));
}
.card__plate {
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--r);
  background-color: var(--stock);
  background-image: var(--rosette), var(--guilloche);
  background-repeat: no-repeat, repeat;
  background-size: 74cqw 74cqw, 78cqw auto;
  background-position: 62% 46%, 0 0;
  box-shadow: inset 1.5px 1.5px 0 rgba(255, 255, 255, 0.9), inset -1.5px -1.5px 0 rgba(17, 17, 17, 0.16);
}
.card--hero:not(.card--blank) .card__shadow,
.card--hero:not(.card--blank) .card__core,
.card--hero:not(.card--blank) .card__plate,
.card--hero:not(.card--blank) .card__side::before {
  border-radius: 0;
  clip-path: var(--shape);
}

/* ── foil stripe on the left edge: hard holographic bands that slide with the tilt ── */
.card__foil {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6.4cqw;
  overflow: hidden;
  box-shadow: inset -1px 0 0 rgba(17, 17, 17, 0.45);
}
.card__foil-bands {
  position: absolute;
  left: -20%;
  right: -20%;
  top: -60%;
  height: 220%;
  background-image: var(--foil);
  background-size: 100% 30cqw;
  background-repeat: repeat-y;
  transform: translateY(var(--fy, 0px)) skewY(-14deg);
}
.card__foil-text {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  writing-mode: vertical-rl;
  font-family: var(--f-display);
  font-size: 2.5cqw;
  line-height: 6.4cqw;
  letter-spacing: 0.34em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  color: rgba(17, 17, 17, 0.8);
}

/* ── the punched hang hole: you look through the card at the ground ─────────── */
.card__punch {
  position: absolute;
  left: 50%;
  top: 3.3cqw;
  width: 12.4cqw;
  height: 4.2cqw;
  margin-left: -6.2cqw;
  border-radius: 99px;
  background-color: var(--ground);
  background-image: radial-gradient(circle at 50% 50%, var(--ground-dot) 0 2.6px, transparent 3.1px), radial-gradient(circle at 50% 50%, var(--ground-dot) 0 2.6px, transparent 3.1px);
  background-size: 12px 12px, 12px 12px;
  background-position: 0 0, 6px 6px;
  box-shadow: inset 0.55cqw 0.75cqw 0 rgba(0, 0, 0, 0.66), inset -0.3cqw -0.45cqw 0 var(--core);
  pointer-events: none;
}

/* ── gloss: ONE hard light band, moved by the tilt. Then the grain over everything. ── */
.card__light {
  position: absolute;
  top: -12%;
  left: 0;
  width: 30cqw;
  height: 124%;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.27) 0 60%, transparent 60% 76%, rgba(255, 255, 255, 0.15) 76% 100%);
  transform: translateX(var(--lx, 16cqw)) skewX(-16deg);
}
.card__grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: var(--tex-grain);
  background-size: 256px 256px;
}

/* ── the folded corner: TURN OVER ───────────────────────────────────────────── */
.card__corner {
  position: absolute;
  right: 0;
  bottom: 0;
  width: var(--cut);
  height: var(--cut);
  background: linear-gradient(135deg, var(--core) 0 28%, #DDD6C3 28% 43%, var(--core) 43% 47.4%, var(--ink) 47.4% 50%, transparent 50%);
  box-shadow: -1.5px -1.5px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.card__corner span {
  position: absolute;
  left: 35%;
  top: 35%;
  font-family: var(--f-display);
  font-size: 2.9cqw;
  line-height: 1;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--ink);
  transform: translate(-50%, -50%) rotate(-45deg);
}
@media (hover: hover) {
  .card__corner:hover {
    background: linear-gradient(135deg, var(--yellow) 0 47.4%, var(--ink) 47.4% 50%, transparent 50%);
  }
}
.card__corner:focus-visible {
  outline: none;
  background: linear-gradient(135deg, var(--yellow) 0 47.4%, var(--ink) 47.4% 50%, transparent 50%);
  box-shadow: -4px -4px 0 var(--ink);
}
.card__corner:active {
  background: linear-gradient(135deg, var(--orange) 0 47.4%, var(--ink) 47.4% 50%, transparent 50%);
}
.card :focus-visible {
  outline-color: var(--ink);
  outline-offset: 2px;
}

/* ── the face: what is printed on the card ──────────────────────────────────── */
.card__face {
  position: absolute;
  inset: 0;
  display: grid;
  min-width: 0;
  font-family: var(--f-mono);
  color: var(--ink);
}
/* hero, portrait (a phone) */
.card--hero .card__face {
  padding: 10.2cqw 1.5cqw 0 10.6cqw;
  grid-template-columns: minmax(0, 1fr) 3.4cqw;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    'top top'
    'id id'
    'num marks'
    'money marks'
    'band band';
  column-gap: 1.6cqw;
  row-gap: 1.8cqw;
}
.card__flash {
  position: absolute;
  inset: 0;
  display: none;
  background: var(--ink);
}
.card.is-flash .card__flash {
  display: block;
}

.card__top {
  grid-area: top;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 3cqw;
  padding-right: 3.6cqw;
  white-space: nowrap;
  text-transform: uppercase;
}
.card__no {
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 3.2cqw;
  letter-spacing: 0.04em;
}
.card__buys {
  min-width: 0;
  overflow: hidden;
  font-family: var(--f-display);
  font-size: 3.5cqw;
  letter-spacing: 0.04em;
  text-align: right;
}

.card__id {
  grid-area: id;
  display: flex;
  align-items: center;
  gap: 3cqw;
  min-width: 0;
  padding-right: 3.6cqw;
}
.card .coin-sticker {
  --px: 19cqw !important; /* the size comes from the card, not from the px the sticker was drawn at */
  margin-left: -5.4cqw; /* stuck on over the edge of the foil */
}
.card__names {
  flex: 1;
  min-width: 0;
}
.card__ticker {
  overflow-x: clip;
  font-family: var(--f-display);
  font-size: 12.6cqw;
  line-height: 1.02;
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-shadow: 0.05em 0.05em 0 var(--spot);
}
.card__name {
  overflow: hidden;
  margin-top: 0.4cqw;
  font-weight: 700;
  font-size: 3.2cqw;
  line-height: 1.2;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* the giant numeral: the meter. Ink is drawn on the canvas, stamps land on top. */
.card__num {
  grid-area: num;
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 0;
}
button.card__num {
  cursor: pointer;
}
button.card__num:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: -3px;
}
.card__ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
}
.card__stamps {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.card .card__stamp {
  position: absolute;
  left: var(--x, 20%);
  top: var(--y, 20%);
  font-size: 7.6cqw;
}
.card .card__stamp--s {
  font-size: 5.6cqw;
}
.card .card__stamp--m {
  font-size: 7.6cqw;
}
.card .card__stamp--l {
  font-size: 10.2cqw;
}
.card__stamp-src {
  display: block;
  margin-top: 0.14em;
  font-size: 0.56em;
  letter-spacing: 0.06em;
}
.card__funded {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.card__funded .stamp {
  --rot: -9deg;
  font-size: 16cqw;
}

.card__money {
  grid-area: money;
  min-width: 0;
}
.card__in,
.card__roll-n {
  overflow-x: clip;
  font-family: var(--f-display);
  font-size: 15cqw;
  line-height: 1.02;
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.card__togo,
.card__roll-w {
  min-height: 2.7em;
  font-weight: 700;
  font-size: 3.8cqw;
  line-height: 1.32;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.card__togo span {
  display: inline-block;
  margin-right: 1.1em;
  white-space: nowrap;
}
.card__togo .card__dry {
  white-space: normal;
  margin-right: 0;
}
.card__roll {
  display: none;
}
.card.is-rolling .card__in,
.card.is-rolling .card__togo {
  display: none;
}
.card.is-rolling .card__roll {
  display: block;
}

/* print details down the right edge: colour bar, edge barcode, register cross */
.card__marks {
  grid-area: marks;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 2cqw;
  min-height: 0;
  padding: 1cqw 0 0.6cqw;
}
.card__swatches {
  display: grid;
  flex: none;
}
.card__swatches i {
  display: block;
  width: 2.5cqw;
  height: 2.5cqw;
}
.card__swatches i:nth-child(1) {
  background: var(--spot);
}
.card__swatches i:nth-child(2) {
  background: var(--green);
}
.card__swatches i:nth-child(3) {
  background: var(--red);
}
.card__swatches i:nth-child(4) {
  background: var(--ink);
}
.card__swatches i:nth-child(5) {
  background-color: var(--stock);
  background-image: var(--tex-halftone);
  background-size: 1.6cqw 1.6cqw;
  box-shadow: inset 0 0 0 1px var(--ink);
}
.card__bars {
  flex: 1;
  width: 3cqw;
  min-height: 0;
  max-height: 30cqw;
  background-color: var(--paper);
  background-image: var(--bars, none);
}
.card__reg {
  position: relative;
  flex: none;
  width: 2.6cqw;
  height: 2.6cqw;
  border: 1px solid var(--ink);
  border-radius: 50%;
}
.card__reg::before,
.card__reg::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  background: var(--ink);
}
.card__reg::before {
  width: 160%;
  height: 1px;
  transform: translate(-50%, -50%);
}
.card__reg::after {
  width: 1px;
  height: 160%;
  transform: translate(-50%, -50%);
}

/* the printed band along the bottom */
.card__band {
  grid-area: band;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5cqw;
  min-width: 0;
  min-height: 17.5cqw;
  margin: 0 -1.5cqw 0 -4.2cqw;
  padding: 2cqw calc(var(--cut) + 0.5cqw) 1.8cqw 4.2cqw;
  background-color: var(--ink);
  color: var(--cream);
}
.card--gold .card__band {
  background-color: var(--gold-1);
  background-image: var(--foil-gold);
  color: var(--ink);
  box-shadow: inset 0 0.5cqw 0 var(--ink);
}
.card__band-line {
  font-family: var(--f-display);
  font-size: 4.7cqw;
  line-height: 1.04;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.card--gold .card__band-line {
  font-size: 4.3cqw;
}
.card__last {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 2.2cqw;
  font-weight: 700;
  font-size: 3.1cqw;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.card__proof {
  position: relative;
  font-family: var(--f-display);
  font-size: 4.4cqw;
  line-height: 1;
  letter-spacing: 0.07em;
  text-decoration: underline;
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.16em;
  color: var(--yellow);
  cursor: pointer;
  touch-action: manipulation;
}
.card__proof::after {
  content: '';
  position: absolute;
  inset: -4.6cqw -3cqw;
}
.card--gold .card__proof {
  color: var(--ink);
}
.card__proof:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
.card__micro {
  overflow: hidden;
  max-height: 2.4em;
  font-size: max(1.5cqw, 5px);
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.74;
}

/* ── the back ───────────────────────────────────────────────────────────────── */
.card__side--rear .card__plate {
  background-image: var(--guilloche);
  background-repeat: repeat;
  background-size: 78cqw auto;
  background-position: 0 0;
}
.card__rear {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-family: var(--f-mono);
  color: var(--ink);
}
.card__mag {
  flex: none;
  height: 14cqw;
  margin-top: 7.5cqw;
  background-color: #15130F;
  background-image: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 3px);
  box-shadow: 0 0.5cqw 0 rgba(17, 17, 17, 0.2);
}
/* signature panel: the wallet state is written here in marker */
.card__sig {
  flex: none;
  min-height: 12cqw;
  margin: 4cqw 5cqw 0;
  padding: 1.6cqw 3cqw;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(-58deg, rgba(17, 17, 17, 0.07) 0 1px, transparent 1px 5px), repeating-linear-gradient(58deg, rgba(17, 17, 17, 0.07) 0 1px, transparent 1px 5px);
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.32);
  font-family: var(--f-marker);
  font-size: 5.6cqw;
  line-height: 1.12;
  text-transform: uppercase;
  color: var(--ink);
}
.card__sig:empty::before {
  content: attr(data-label);
  font-family: var(--f-mono);
  font-size: max(1.9cqw, 6px);
  letter-spacing: 0.1em;
  color: rgba(17, 17, 17, 0.5);
}
/* the empty box the page fills (rules, bag ruler, trust lines, barcodes) */
.card__back {
  flex: 1;
  min-height: 0;
  margin: 3cqw 5cqw 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  font-size: 3.6cqw;
  line-height: 1.35;
}
.card__foot {
  flex: none;
  display: flex;
  align-items: center;
  min-height: var(--cut);
  padding: 0 calc(var(--cut) + 1cqw) 0 5cqw;
  overflow: hidden;
  font-size: max(2.3cqw, 7px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(17, 17, 17, 0.7);
}

/* hero, landscape: its box is 720 px or wider */
@container slot (min-width: 720px) {
  /* a container cannot restyle itself from its own query: the rig carries the landscape measures */
  .card--hero .card__rig {
    --r: 3.6cqw;
    --cut: 8.4cqw;
    width: min(100%, var(--card-hero-land-max));
    aspect-ratio: var(--card-hero-land-ratio);
  }
  .card--hero .card__plate {
    background-size: 52cqw 52cqw, 46cqw auto;
    background-position: 82% 40%, 0 0;
  }
  .card--hero .card__side--rear .card__plate {
    background-size: 46cqw auto;
    background-position: 0 0;
  }
  .card--hero .card__foil {
    width: 5.2cqw;
  }
  .card--hero .card__foil-text {
    font-size: 1.9cqw;
    line-height: 5.2cqw;
  }
  .card--hero .card__punch {
    top: 2.1cqw;
    width: 8cqw;
    height: 2.8cqw;
    margin-left: -4cqw;
  }
  .card--hero .card__corner span {
    font-size: 1.7cqw;
  }
  .card--hero .card__face {
    padding: 2.4cqw 1.2cqw 0 8.2cqw;
    grid-template-columns: minmax(0, 30fr) minmax(0, 57fr) 2.4cqw;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      'top top top'
      'id num marks'
      'money num marks'
      'band band band';
    column-gap: 1.6cqw;
    row-gap: 1.2cqw;
  }
  .card--hero .card__top {
    padding-right: 2.2cqw;
  }
  .card--hero .card__no {
    font-size: 1.85cqw;
  }
  .card--hero .card__buys {
    font-size: 2.3cqw;
  }
  .card--hero .card__id {
    flex-direction: column;
    align-items: flex-start;
    gap: 1cqw;
    padding-right: 0;
  }
  .card--hero .coin-sticker {
    --px: 12.5cqw !important;
    margin-left: -4.4cqw;
  }
  .card--hero .card__names {
    flex: none;
    width: 100%;
  }
  .card--hero .card__ticker {
    font-size: 7.6cqw;
  }
  .card--hero .card__name {
    font-size: 1.9cqw;
  }
  .card--hero .card__money {
    align-self: end;
    padding-bottom: 1cqw;
  }
  .card--hero .card__in,
  .card--hero .card__roll-n {
    font-size: 8cqw;
  }
  .card--hero .card__togo,
  .card--hero .card__roll-w {
    font-size: 2cqw;
  }
  .card--hero .card__stamp,
  .card--hero .card__stamp--m {
    font-size: 4.5cqw;
  }
  .card--hero .card__stamp--s {
    font-size: 3.3cqw;
  }
  .card--hero .card__stamp--l {
    font-size: 6.1cqw;
  }
  .card--hero .card__funded .stamp {
    font-size: 10.5cqw;
  }
  .card--hero .card__swatches i {
    width: 1.7cqw;
    height: 1.7cqw;
  }
  .card--hero .card__swatches i:nth-child(5) {
    background-size: 1.1cqw 1.1cqw;
  }
  .card--hero .card__bars {
    width: 2cqw;
    max-height: 20cqw;
  }
  .card--hero .card__reg {
    width: 1.8cqw;
    height: 1.8cqw;
  }
  .card--hero .card__band {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    gap: 0.3cqw 3cqw;
    min-height: 9.2cqw;
    margin: 0 -1.2cqw 0 -3cqw;
    padding: 1.2cqw calc(var(--cut) + 0.5cqw) 1.1cqw 3cqw;
  }
  .card--hero .card__band-line,
  .card--hero.card--gold .card__band-line {
    font-size: 2.5cqw;
  }
  .card--hero .card__last {
    font-size: 1.75cqw;
    gap: 0 1.6cqw;
  }
  .card--hero .card__proof {
    font-size: 2.4cqw;
  }
  .card--hero .card__proof::after {
    inset: -1.8cqw -1.4cqw;
  }
  .card--hero .card__micro {
    flex-basis: 100%;
    font-size: max(0.95cqw, 5px);
  }
  .card--hero .card__mag {
    height: 9.5cqw;
    margin-top: 5.8cqw;
  }
  .card--hero .card__sig {
    min-height: 6.4cqw;
    margin: 2.2cqw 4cqw 0;
    padding: 0.9cqw 2cqw;
    font-size: 3cqw;
  }
  .card--hero .card__back {
    margin: 1.8cqw 4cqw 0;
    font-size: 1.9cqw;
  }
  .card--hero .card__foot {
    padding-left: 4cqw;
    font-size: max(1.25cqw, 7px);
  }
}

/* ── deck card (the rack): about 340 x 212, the whole card is a link ────────── */
.card--deck .card__plate {
  background-size: 66cqw 66cqw, 74cqw auto;
  background-position: 96% 70%, 0 0;
}
.card--deck .card__foil {
  width: 5.6cqw;
}
.card--deck .card__foil-text {
  font-size: 2.2cqw;
  line-height: 5.6cqw;
}
.card--deck .card__punch {
  top: 2.4cqw;
  width: 10cqw;
  height: 3.4cqw;
  margin-left: -5cqw;
}
.card--deck .card__light {
  width: 24cqw;
}
.card--deck .card__face {
  padding: 3.4cqw 3.6cqw 3cqw 8.8cqw;
  grid-template-columns: minmax(0, 47fr) minmax(0, 43fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas:
    'top top'
    'id num'
    'money num';
  column-gap: 2cqw;
  row-gap: 1.2cqw;
}
.card--deck .card__top {
  padding-right: 0;
}
.card--deck .card__no,
.card__out {
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 3.2cqw;
  letter-spacing: 0.04em;
}
.card--deck .card__id {
  gap: 2.4cqw;
  padding-right: 0;
}
.card--deck .coin-sticker {
  --px: 15cqw !important;
  margin-left: -4.6cqw;
}
.card--deck .card__ticker {
  font-size: 9.6cqw;
}
.card--deck .card__money {
  align-self: end;
}
.card--deck .card__in {
  font-size: 11cqw;
}
.card--deck .card__togo {
  min-height: 2.64em;
  font-size: 3.2cqw;
}
.card--deck .card__togo span {
  display: block;
  margin-right: 0;
}
.card--deck .card__stamp,
.card--deck .card__stamp--m {
  font-size: 6.4cqw;
}
.card--deck .card__stamp--s {
  font-size: 5cqw;
}
.card--deck .card__stamp--l {
  font-size: 8cqw;
}
.card--deck .card__funded .stamp {
  font-size: 11cqw;
}
@media (hover: hover) {
  .card--deck:hover .card__tilt {
    transform: translate(-3px, -3px);
  }
}
.card--deck:active .card__tilt {
  transform: translate(3px, 3px);
}
.card--deck:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

/* ── blank card: the same body with an empty face to fill ───────────────────── */
.card--blank,
.card--blank .card__rig {
  --cut: 0px;
}
.card--blank .card__face {
  display: block;
  padding: 10.2cqw 5cqw 5cqw 10.6cqw;
}
.card--blank.card--deck .card__face {
  padding: 3.4cqw 3.6cqw 3cqw 8.8cqw;
}
@container slot (min-width: 720px) {
  .card--blank.card--hero .card__face {
    padding: 2.4cqw 3.4cqw 3.4cqw 8.2cqw;
  }
}

/* ── a live hero: hands on it ───────────────────────────────────────────────── */
.card.is-live .card__rig {
  touch-action: pan-y;
}
.card.is-live .card__tilt {
  will-change: transform;
}
.card.is-live .card__foil-bands,
.card.is-live .card__light {
  will-change: transform;
}

/* ── when a card fills: it slides off, the next one drops in and bounces ────── */
.card.is-dropping {
  z-index: 30;
}
.card.is-sliding .card__rig {
  animation: card-slide 440ms cubic-bezier(0.55, 0, 1, 0.55) both;
}
.card.is-gone .card__rig {
  visibility: hidden;
}
.card.is-landing .card__rig {
  animation: card-land 560ms linear both;
}
.card.is-swap .card__rig {
  animation: card-swap 340ms linear both;
}
@keyframes card-slide {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  16% {
    transform: translateY(-3%) rotate(-1deg);
  }
  100% {
    transform: translateY(130%) rotate(6deg);
  }
}
@keyframes card-land {
  0% {
    transform: translateY(-150%) rotate(-5deg);
    animation-timing-function: cubic-bezier(0.5, 0, 1, 0.6);
  }
  52% {
    transform: translateY(0) rotate(0deg);
    animation-timing-function: cubic-bezier(0, 0.6, 0.4, 1);
  }
  68% {
    transform: translateY(-5.5%) rotate(1.2deg);
    animation-timing-function: cubic-bezier(0.6, 0, 1, 0.5);
  }
  84% {
    transform: translateY(0) rotate(0deg);
    animation-timing-function: cubic-bezier(0, 0.6, 0.4, 1);
  }
  92% {
    transform: translateY(-1.4%) rotate(-0.4deg);
    animation-timing-function: cubic-bezier(0.6, 0, 1, 0.5);
  }
  100% {
    transform: translateY(0) rotate(0deg);
  }
}
@keyframes card-swap {
  0% {
    transform: translateY(-34%) rotate(-3deg);
    animation-timing-function: cubic-bezier(0.5, 0, 1, 0.6);
  }
  60% {
    transform: translateY(0) rotate(0deg);
    animation-timing-function: cubic-bezier(0, 0.6, 0.4, 1);
  }
  80% {
    transform: translateY(-4%) rotate(0.8deg);
    animation-timing-function: cubic-bezier(0.6, 0, 1, 0.5);
  }
  100% {
    transform: translateY(0) rotate(0deg);
  }
}

/* ── past card (the pile): a mini card with its status stamp and a torn receipt stub ── */
.past {
  container: past / inline-size;
  position: relative;
  width: 100%;
  max-width: 640px;
  color: var(--ink);
}
.past__in {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0 8px 8px 0;
}
.past__card {
  --spot: var(--orange);
  --stock: var(--cream);
  --foil: linear-gradient(180deg, #E9ECEE 0 11%, #8F9498 11% 16%, #7FE0B0 16% 30%, #F2D675 30% 39%, #E9ECEE 39% 46%, #FF9A8B 46% 60%, #C9CCCF 60% 74%, #39B8A6 74% 83%, #F4EFE2 83% 90%, #8F9498 90% 100%);
  --guilloche: var(--tex-guilloche);
  container: mini / inline-size;
  position: relative;
  z-index: 1;
  display: block;
  flex: none;
  width: min(100%, var(--card-mini-max));
  aspect-ratio: var(--card-mini-ratio);
  color: var(--ink);
  text-decoration: none;
}
.past--gold .past__card {
  --spot: var(--gold-1);
  --stock: #F6EDCF;
  --foil: linear-gradient(180deg, var(--gold-1) 0 16%, var(--gold-2) 16% 30%, #FFF3B8 30% 36%, var(--gold-2) 36% 44%, var(--gold-1) 44% 62%, var(--gold-3) 62% 72%, var(--gold-1) 72% 86%, var(--gold-2) 86% 100%);
  --guilloche: var(--tex-guilloche-gold);
}
a.past__card {
  cursor: pointer;
}
a.past__card:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 4px;
}
.past__plate {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 3cqw;
  padding: 0 2cqw 0 7.2cqw;
  overflow: hidden;
  border-radius: 3.8cqw;
  background-color: var(--stock);
  background-image: var(--tex-grain), var(--guilloche);
  background-size: 256px 256px, 62cqw auto;
  /* the edge, the classic way: stacked hard shadows, then the ground shadow */
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.9), 1px 1px 0 var(--core), 2px 2px 0 var(--core), 3px 3px 0 #A9A28F, 8px 8px 0 var(--ink);
}
.past__foil {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4.4cqw;
  background-image: var(--foil);
  background-size: 100% 22cqw;
  box-shadow: inset -1px 0 0 rgba(17, 17, 17, 0.45);
}
.past__usd {
  flex: none;
  font-family: var(--f-display);
  font-size: min(17cqw, calc(51cqw / var(--chars, 3)));
  line-height: 1;
  letter-spacing: 0;
  color: var(--spot);
  text-shadow: 0.04em 0.04em 0 var(--ink);
}
.past--gold .past__usd {
  color: transparent;
  text-shadow: none;
  background-image: var(--foil-gold);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-stroke: 0.022em var(--ink);
}
.past__info {
  flex: 1;
  min-width: 0;
  font-family: var(--f-mono);
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}
.past__no,
.past__ago {
  font-size: 3.4cqw;
  line-height: 1.25;
  letter-spacing: 0.04em;
}
.past__ago {
  font-weight: 400;
}
.past__ticker {
  overflow: hidden;
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 8.6cqw;
  line-height: 1.04;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
}
.past__winner {
  font-size: 3.8cqw;
  line-height: 1.3;
  letter-spacing: 0.01em;
}
.past__status {
  position: absolute;
  top: 0;
  right: 2.2cqw;
  bottom: 0;
  display: flex;
  align-items: center;
  pointer-events: none;
}
.past__status .stamp {
  font-size: 4.6cqw;
}
.past__left {
  display: block;
  margin-top: 0.16em;
  font-size: 0.62em;
  letter-spacing: 0.06em;
}
.past.is-void .past__usd {
  color: rgba(17, 17, 17, 0.3);
  text-shadow: none;
  background-image: none;
  -webkit-text-stroke: 0;
}
.past .past__yours,
.past .past__again {
  position: absolute;
  z-index: 3;
}
.past .past__yours {
  top: -15px;
  right: 6px;
}
.past .past__again {
  left: 20%;
  bottom: -9px;
  font-size: 14px;
  --rot: 2deg;
}
/* the stub: tucked under the card, torn off at the bottom */
.past__stub {
  position: relative;
  z-index: 0;
  align-self: flex-end;
  width: min(84%, 268px);
  margin: -7px 14px 0 0;
  filter: drop-shadow(3px 3px 0 var(--ink));
  transform: rotate(1.3deg);
}
.past__stub .stub {
  padding-top: 15px;
}
.past__proof {
  font-family: var(--f-mono);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
@container past (min-width: 560px) {
  .past__in {
    flex-direction: row;
  }
  .past__card {
    width: min(64%, var(--card-mini-max));
  }
  .past__stub {
    align-self: flex-start;
    width: auto;
    flex: 1;
    max-width: 236px;
    margin: 12px 0 0 -8px;
  }
  .past__stub .stub {
    padding-top: 10px;
    padding-left: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card__flip {
    transition: none;
  }
}
