.companion-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  border-top: 2px solid var(--ink);
  background: var(--ink);
}
.companion-actions .choose-button { border-top: 0; }
#collection-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 4px 7px;
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}
#collection-count {
  white-space: nowrap;
  font: 800 17px/1 var(--number);
  font-variant-numeric: tabular-nums;
}
#collection-button:hover { background: var(--lime); }
#collection {
  width: min(544px, calc(100% - 24px));
  max-height: calc(100dvh - 16px);
  overscroll-behavior: contain;
}
#collection .dialog-head {
  position: sticky;
  top: 0;
  z-index: 6;
  gap: 8px;
  padding: 6px 10px 6px 14px;
  background: var(--paper);
}
#collection .dialog-head h2 {
  font: 900 clamp(18px, 4.2vw, 25px)/1.25 var(--body);
  letter-spacing: -.025em;
}
#collection-status {
  margin: 0 0 0 auto;
  white-space: nowrap;
  font: 800 17px/1.2 var(--number), var(--body);
  font-variant-numeric: tabular-nums;
}
#collection .dialog-head .close { flex: 0 0 44px; }
.collection-content {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 12px 14px 14px;
  background: var(--paper);
}
.group-poster {
  --print-ink: #101544;
  --print-paper: #fbf2dd;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  container-type: inline-size;
  width: min(100%, max(190px, calc((100dvh - var(--poster-reserved-height, 150px)) * .94)));
  aspect-ratio: 100 / 107;
  margin: 0;
  border: 2px solid var(--print-ink);
  background:
    radial-gradient(circle at 1px 1px, #10154413 .65px, transparent .8px) 0 0 / 5px 5px,
    var(--print-paper);
  color: var(--print-ink);
}
.group-poster::before {
  content: "";
  position: absolute;
  inset: 3.2%;
  border: 1px solid #10154442;
  z-index: -1;
  pointer-events: none;
}
.group-poster::after {
  content: "";
  position: absolute;
  inset: 1.65%;
  border: .26cqw solid var(--print-ink);
  z-index: -1;
  opacity: 0;
  pointer-events: none;
}
.print-title {
  position: absolute;
  inset: 5% 5% auto;
  text-align: center;
  font: 400 12.3cqw/1.02 var(--display);
  letter-spacing: .012em;
}
.print-animals { position: absolute; inset: 0; }
.print-animal {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--w);
  height: var(--h);
  transform: translate(-50%, -50%) rotate(var(--tilt));
}
.print-animal::before {
  content: "";
  position: absolute;
  inset: 17% 1% 5%;
  background: color-mix(in srgb, var(--pet-color) 62%, var(--print-paper));
  clip-path: polygon(4% 10%, 87% 0, 100% 79%, 79% 99%, 0 90%);
}
.print-animal:nth-child(even)::before {
  clip-path: polygon(10% 0, 96% 9%, 97% 83%, 11% 100%, 0 31%);
}
.print-animal img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: .31;
  filter: brightness(0);
}
.print-animal[data-owned] img { opacity: 1; filter: none; }
.print-mystery {
  position: absolute;
  top: 7%;
  right: 6%;
  font: 950 5.6cqw/.9 var(--body);
  color: var(--print-ink);
  -webkit-text-stroke: .65cqw var(--print-paper);
  paint-order: stroke fill;
  transform: rotate(7deg);
}
.print-animal[data-owned] .print-mystery { visibility: hidden; }
.group-poster.is-printed::before { border-color: var(--print-ink); }
.group-poster.is-printed:not(.is-inking)::after { opacity: 1; }
.group-poster.is-printed .print-animal::before {
  background:
    radial-gradient(circle, #10154425 .55px, transparent .85px) 0 0 / 3px 3px,
    color-mix(in srgb, var(--pet-color) 85%, var(--print-paper));
}
#collection-ink {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#collection-guide { margin: 0; font-size: 12px; line-height: 1.5; text-align: center; }
#collection[data-complete] { --poster-reserved-height: 229px; }
#collection-tools { display: grid; width: min(100%, 450px); gap: 6px; }
.collection-share-buttons { display: grid; grid-template-columns: 1fr 1.15fr; gap: 6px; }
.collection-share-buttons .action {
  min-height: 44px;
  padding: 6px 8px;
  font-size: clamp(13px, 3.1vw, 15px);
  line-height: 1.35;
  text-align: center;
  white-space: normal;
}
#collection-save { color: var(--ink); text-decoration: none; }
#collection-save:hover { background: var(--lime); }
#collection-share:disabled { opacity: .6; cursor: wait; }
#collection-share-status { margin: 0; font-size: 12px; line-height: 1.45; text-align: center; }
#collection-share-status:empty { display: none; }
.collection-share-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 14px; }
.collection-share-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font-size: 13px; }
#collection-tools a:focus-visible { outline: 2px solid var(--focus-ink); outline-offset: 2px; }
#collection-replay { margin: 0; font-size: 13px; background: var(--paper); color: var(--ink); }
.print-animal.is-arriving img { animation: poster-arrival 560ms cubic-bezier(.22,.72,.24,1) both; }
.print-animal:is([data-pet="crab"], [data-pet="turtle"]) {
  --arrival-rise: -12%;
  --arrival-rebound: -1%;
}
.print-animal.is-arriving .print-mystery {
  visibility: visible;
  animation: poster-question-out 320ms ease-out both;
}
.is-celebrating .print-animal img { animation: poster-group 520ms var(--cheer-wait) both; }
.is-celebrating::after { animation: poster-frame 480ms 100ms both; }
@keyframes poster-arrival {
  0% { opacity: .31; filter: brightness(0); transform: translateY(var(--arrival-rise, -30%)) scale(.82); }
  42% { opacity: 1; filter: none; transform: translateY(3%) scale(1.13,.9); }
  68% { transform: translateY(var(--arrival-rebound, -5%)) scale(.97,1.04); }
  100% { transform: none; }
}
@keyframes poster-question-out {
  0%, 22% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-20%) rotate(22deg) scale(.6); }
}
@keyframes poster-group {
  0%, 100% { transform: none; }
  30% { transform: translateY(-8%) rotate(var(--jump)); }
  63% { transform: scale(1.04,.96); }
}
@keyframes poster-frame {
  0% { opacity: 0; transform: scale(.96); }
  100% { opacity: 1; transform: none; }
}
@media (max-width: 770px), (orientation: landscape) and (max-height: 520px) {
  .companion-actions {
    grid-column: 3;
    grid-row: 1;
    grid-template-columns: auto auto;
    align-items: stretch;
    gap: 4px;
    border: 0;
    background: transparent;
  }
  .companion-actions .choose-button { grid-area: auto; width: 44px; }
  #collection-button {
    flex-direction: column;
    gap: 3px;
    min-width: 54px;
    border: 1px solid var(--ink);
    font-size: 11px;
    line-height: 1;
  }
  #collection-count { font-size: 14px; }
  .poster-face { grid-template-columns: clamp(37px, 15vw, 70px) minmax(0,1fr) auto; }
}
@media (orientation: landscape) and (max-height: 520px) and (min-width: 510px) {
  .poster-face { grid-template-columns: 35px minmax(0,1fr) auto; }
  .companion-actions .choose-button { min-height: 44px; width: 42px; }
  .companion-actions .choose-button .icon { display: none; }
  #collection-button { min-width: 49px; padding-inline: 4px; font-size: 10px; }
  .collection-content {
    grid-template-columns: minmax(0,1fr) minmax(110px, .58fr);
    grid-template-rows: 1fr;
    align-items: end;
    gap: 12px;
    padding-block: 7px;
  }
  .group-poster { width: min(100%, calc((100dvh - 92px) * .93)); }
  .collection-share-buttons { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .print-animal img, .print-mystery, .group-poster::after { animation: none !important; }
}
