/* Chase Foil: five flat inks, and holographic foil reserved for the rarest results. */

@font-face {
  font-family: "Anybody";
  src: url("fonts/anybody.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 50% 150%;
  font-display: swap;
}

@font-face {
  font-family: "Hanken Grotesk";
  src: url("fonts/hanken.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@property --mx { syntax: "<percentage>"; inherits: true; initial-value: 50%; }
@property --my { syntax: "<percentage>"; inherits: true; initial-value: 50%; }

@view-transition { navigation: auto; }

:root {
  --cobalt: #1533f5;
  --pearl: #f4f2ea;
  --navy: #0b1147;
  --gold: #ffc400;
  --magenta: #ff2a6d;

  --rule: rgb(11 17 71 / 0.16);
  --lift: 0 28px 56px rgb(0 0 0 / 0.3);
  --lift-small: 0 10px 22px rgb(0 0 0 / 0.2);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --font-display: "Anybody", "Hanken Grotesk", "Segoe UI", sans-serif;
  --font-text: "Hanken Grotesk", "Noto Sans Thai", "Leelawadee UI", "Thonburi", "Segoe UI", sans-serif;

  --foil-bands: linear-gradient(115deg, #ff1a78, #ffc400, #12d8ff, #1238ff, #b01cff, #ff1a78, #ffc400, #12d8ff, #1238ff, #b01cff, #ff1a78);
  --foil-warm: linear-gradient(115deg, #ff1a78, #ff5a2a, #ffc400, #ff1a78, #b01cff, #ff1a78, #ff5a2a, #ffc400, #ff1a78);
  /* Bright bands only: foil.py checks navy text holds 4.5:1 on it. */
  --foil-field: url("images/foil-field.webp");

  scrollbar-color: var(--on-ground) transparent;
  scrollbar-width: thin;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
/* Rapid taps on Reroll must not double-tap zoom the page. Pinch zoom still works. */
html, a, button, input, select, label { touch-action: manipulation; }

body {
  --ground: var(--cobalt);
  --on-ground: var(--pearl);
  margin: 0;
  min-height: 100dvh;
  background-color: var(--ground);
  color: var(--on-ground);
  font-family: var(--font-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  caret-color: var(--magenta);
  transition: color .22s linear;
}

body[data-ink="gold"] { --ground: var(--gold); --on-ground: var(--navy); }
body[data-ink="magenta"] { --ground: var(--magenta); --on-ground: var(--navy); }
body[data-ink="foil"] { --ground: var(--pearl); --on-ground: var(--navy); }

::selection { background: var(--gold); color: var(--navy); }

:focus-visible {
  outline: 3px solid var(--on-ground);
  outline-offset: 3px;
}

.sheet, .custom { --on-ground: var(--navy); }

h1, h2, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
img { display: block; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Ground and flood */

.ground {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--ground);
  pointer-events: none;
}

body[data-ink="foil"] .ground:not(:has(.disc))::before {
  content: "";
  position: absolute;
  inset: -240px;
  background: var(--foil-field) 240px 240px / 1200px 1200px;
  animation: ground-drift 26s ease-in-out infinite alternate;
}

@keyframes ground-drift {
  to { transform: translate3d(200px, 130px, 0); }
}

.disc {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}

.disc-gold { background: var(--gold); }
.disc-magenta { background: var(--magenta); }
.disc-foil { background: var(--foil-field) 0 0 / 1200px 1200px; }

/* Top bar */

.top {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 14px);
  height: 84px;
  padding-inline: clamp(12px, 2.5vw, 36px);
}

.top nav { display: contents; }
.top-logo { flex: none; margin-right: clamp(4px, 1vw, 16px); border-radius: 12px; }
.top-logo img { width: auto; height: 68px; }

.tab {
  padding: .55em 1em;
  border-radius: 99px;
  color: var(--on-ground);
  font-size: .9375rem;
  font-weight: 800;
  text-decoration: none;
  text-underline-offset: .25em;
  text-decoration-thickness: 2px;
  white-space: nowrap;
}

.tab:hover { text-decoration-line: underline; }
.tab[aria-current="page"] { background: var(--pearl); color: var(--navy); text-decoration: none; }

/* In the page flow at the foot, never over the top bar, so it can't cover the tally or the tabs. */
.credit {
  padding: 8px 16px 24px;
  color: var(--on-ground);
  font-size: .8125rem;
  font-weight: 600;
  text-align: center;
}
.credit a { color: inherit; font-weight: 800; text-underline-offset: .2em; }

/* Simulator layout */

.sim {
  --press-h: clamp(84px, 11dvh, 104px);
  --card-h: min(calc(100dvh - 84px - var(--strip-h, 0px) - 44px - var(--press-h)), 700px);
  --card-w: calc(var(--card-h) * .669);
  display: grid;
  grid-template-areas: "checklist stage side";
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr) minmax(250px, 300px);
  gap: clamp(16px, 2.2vw, 36px);
  height: calc(100dvh - 84px - var(--strip-h, 0px));
  min-height: 600px;
  padding: 8px clamp(12px, 2.5vw, 36px) clamp(16px, 2.5vh, 32px);
  overflow-x: clip; /* The halo is wider than a phone. It must never widen the page. */
}

/* Set checklist */

.sheet {
  grid-area: checklist;
  align-self: start;
  max-height: 100%;
  overflow: auto;
  padding: 16px 18px 12px;
  border-radius: 16px;
  background: var(--pearl);
  box-shadow: var(--lift-small);
  color: var(--navy);
  scrollbar-color: var(--navy) transparent;
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-stretch: 125%;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.01em;
}

.sheet-count { font-size: .9375rem; font-weight: 800; white-space: nowrap; }
.sheet-sub { margin-bottom: 8px; font-size: .875rem; font-weight: 600; }
.sheet-sub b { font-weight: 800; }

.row {
  --row-h: clamp(30px, calc((100dvh - 236px - var(--strip-h, 0px)) / 18), 46px);
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 3.5em;
  gap: 10px;
  align-items: center;
  min-height: var(--row-h);
  padding-block: 3px;
  border-top: 1.5px solid var(--rule);
}

.row-icon { width: 24px; height: 24px; object-fit: contain; }
.row-main { display: grid; gap: 3px; min-width: 0; }

.row-name {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.15;
}

.row-no { font-size: .75rem; font-weight: 700; }

.row-got {
  flex: none;
  width: 13px;
  height: 13px;
  background: var(--navy);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 8.5 6 13l8.5-10' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.row-got[hidden] { display: none; }

.ruler {
  position: relative;
  display: block;
  height: 6px;
  border-radius: 1px;
  background:
    linear-gradient(90deg, var(--rule) 1.5px, transparent 0) 0 0 / 20% 100%,
    rgb(11 17 71 / 0.07);
}

.ruler i { position: absolute; inset: 0 auto 0 0; background: var(--cobalt); }
.row[data-tier="gold"] .ruler i { background: var(--gold); box-shadow: inset 0 0 0 1px var(--navy); }
.row[data-tier="mythic"] .ruler i { background: var(--magenta); }
.row[data-tier="secret"] .ruler i { background: var(--foil-bands); background-size: 200% 200%; box-shadow: inset 0 0 0 1px var(--navy); }

.row-rate {
  display: grid;
  justify-items: end;
  font-size: .875rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.row-total { font-weight: 600; }

.row.is-current {
  margin-inline: -8px;
  padding-inline: 8px;
  border-radius: 8px;
  border-top-color: transparent;
  background: var(--navy);
  color: var(--pearl);
}

.row.is-current + .row { border-top-color: transparent; }
.row.is-current .row-got { background: var(--pearl); }
.row.is-current .ruler { background: linear-gradient(90deg, rgb(244 242 234 / .3) 1.5px, transparent 0) 0 0 / 20% 100%, rgb(244 242 234 / .16); }
.row.is-current[data-tier="blue"] .ruler i { background: var(--pearl); }

.sheet-note { padding-top: 8px; border-top: 1.5px solid var(--rule); font-size: .75rem; font-weight: 600; }

.page-summon .row {
  --row-h: clamp(44px, calc((100dvh - 390px - var(--strip-h, 0px)) / 6), 62px);
  grid-template-columns: 52px minmax(0, 1fr) 4.8em;
  gap: 8px;
}

.page-summon .row-icon { width: 48px; height: 48px; border-radius: 9px; object-fit: cover; }
.page-summon .row-name { font-size: .9375rem; }

.columns {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 4px;
  font-size: .75rem;
  font-weight: 700;
}

.pity { padding-top: 10px; border-top: 1.5px solid var(--rule); font-size: .9375rem; font-weight: 800; }
.pity-bar { height: 10px; margin-top: 6px; border-radius: 2px; background: rgb(11 17 71 / 0.1); overflow: hidden; }
.pity-bar i { display: block; width: 0; height: 100%; background: var(--magenta); }

/* The card */

.stage {
  grid-area: stage;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.halo {
  position: absolute;
  top: calc(50% - var(--press-h) / 2 + 2px);
  left: 50%;
  z-index: -1;
  width: calc(var(--card-h) * 1.4);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--gold);
  transform: translate(-50%, -50%) scale(0);
  transition: transform .18s linear;
}

body[data-ink="magenta"] .halo,
body[data-ink="foil"] .halo {
  transform: translate(-50%, -50%) scale(1);
  transition: transform .8s var(--ease-out) .24s;
}

body[data-ink="foil"] .halo { background: none; }

body[data-ink="foil"] .halo::before {
  content: "";
  position: absolute;
  inset: 8%;
  background: var(--gold);
  mask: url("images/burst.svg") center / contain no-repeat;
  animation: burst-turn 60s linear infinite;
}

@keyframes burst-turn {
  to { transform: rotate(360deg); }
}

.card {
  --rest: -3.5deg;
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  z-index: 1;
  flex: none;
  width: var(--card-w);
  height: var(--card-h);
  container-type: size;
  perspective: 1400px;
  transform: rotate(var(--rest)) perspective(1200px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .28s var(--ease-out);
}

.card.is-tracking { transition: transform .06s linear; }
.page-reroll .card { view-transition-name: pack-reroll; }
.page-summon .card { view-transition-name: pack-summon; }

.card-flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .5s var(--ease-out);
}

.card.is-down .card-flip { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 4cqh;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  box-shadow: var(--lift);
}

/* Safari only hides a face's back when the face has a 3D transform of its own, so the front gets a do-nothing one. */
.card-front {
  display: flex;
  padding: 2.2cqh;
  background: var(--navy);
  overflow: hidden;
  transform: rotateY(0deg);
}

.card-paper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  padding: 3cqh 3.4cqh;
  border-radius: 2.2cqh;
  background: var(--pearl);
  color: var(--navy);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: max(.75rem, 2.1cqh);
  font-weight: 800;
}

.card-art {
  position: relative;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin-block: 1.8cqh;
  padding: 2.2cqh;
  border-radius: 1.8cqh;
  background: rgb(11 17 71 / 0.07);
  overflow: hidden;
}

.card-art img {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.card[data-art="portrait"] .card-art { padding: 1.6cqh; background: var(--navy); }
.card[data-art="portrait"] .card-art img { max-width: var(--portrait, 34cqh); max-height: var(--portrait, 34cqh); aspect-ratio: 1; object-fit: cover; border-radius: 1.6cqh; }

.card-name {
  width: max-content;
  max-width: none;
  color: var(--cobalt);
  font-family: var(--font-display);
  font-size: 10.4cqh;
  font-stretch: 100%;
  font-weight: 900;
  line-height: .98;
  letter-spacing: -.02em;
}

.card-name span { display: block; }
.word { display: inline-block; }
.card-name span::first-letter, .word::first-letter { font-size: 1.16em; }

.card-rate {
  margin-top: .9cqh;
  font-size: max(.9375rem, 3.1cqh);
  font-weight: 800;
  line-height: 1.2;
}

.card-text {
  margin-top: 1.5cqh;
  padding-top: 1.4cqh;
  border-top: 2px solid var(--navy);
}

.card-text[hidden] { display: none; }

.card-line { font-size: max(.8125rem, 2.55cqh); font-weight: 700; line-height: 1.3; text-wrap: pretty; }
.card-note { margin-top: .8cqh; font-size: max(.75rem, 2.05cqh); font-weight: 600; line-height: 1.3; text-wrap: pretty; }

/* Gold: darkened art window so the icon burns against it */
.card[data-tier="gold"] .card-art { background: var(--navy); }
.card[data-tier="blue"] .card-art { background: var(--cobalt); }
.card[data-tier="blue"] { --disc: var(--pearl); --portrait: 27cqh; }
.card[data-tier="gold"] { --portrait: 30cqh; }
.card[data-tier="mythic"], .card[data-tier="secret"] { --disc: var(--navy); }
.card[data-tier="blue"][data-art="icon"] .card-art img,
.card[data-tier="mythic"][data-art="icon"] .card-art img {
  padding: 6%;
  background: radial-gradient(circle closest-side, var(--disc) calc(100% - 1px), transparent);
}
.card[data-tier="mythic"][data-art="icon"] .card-art img { max-height: 44cqh; }

/* A dual trait sets both icons side by side, the rarer one first. */
.card-art img[hidden] { display: none; }
.card[data-art="pair"] .card-art { gap: 1.2cqh; }
.card[data-art="pair"] .card-art img {
  flex: 1 1 0;
  min-width: 0;
  max-height: 30cqh;
  padding: 5%;
  background: radial-gradient(circle closest-side, var(--disc, transparent) calc(100% - 1px), transparent);
}
.card[data-tier="gold"] .card-name { color: var(--navy); font-stretch: 125%; }
.card[data-tier="blue"] .card-name { font-stretch: 100%; }
.card[data-tier="start"] .card-name { color: var(--navy); font-stretch: 110%; }

/* Mythic and secret: the only foil on the site */
.card[data-tier="mythic"] .card-name,
.card[data-tier="secret"] .card-name { color: var(--magenta); font-stretch: 150%; }

.card[data-tier="mythic"]:not(.is-riffling),
.card[data-tier="secret"]:not(.is-riffling) { animation: foil-drift 11s ease-in-out infinite; }
.card.is-tracking { animation: none !important; }

.card[data-tier="mythic"] { --plate: url("images/foil-mythic.webp"); }
.card[data-tier="secret"] { --plate: url("images/foil-secret.webp"); }

.card[data-tier="mythic"] .card-front,
.card[data-tier="secret"] .card-front,
.card[data-tier="mythic"] .card-art,
.card[data-tier="secret"] .card-art {
  background-image:
    radial-gradient(circle at var(--mx) var(--my), rgb(255 255 255 / .34), rgb(255 255 255 / 0) 42%),
    var(--plate);
  background-color: transparent;
  background-size: 100% 100%, 90cqh 90cqh;
  background-position: 0 0, var(--mx) var(--my);
}

/* Mythic's rim is too thin to carry the stamped stars, so it is bright bands alone. */
.card[data-tier="mythic"] .card-front {
  background-image:
    radial-gradient(circle at var(--mx) var(--my), rgb(255 255 255 / .34), rgb(255 255 255 / 0) 42%),
    var(--foil-warm);
  background-size: 100% 100%, 300% 300%;
}

/* The top portraits are printed in a stamped frame. The sources are too small to go bigger, so rank shows in the frame. */
.card[data-tier="mythic"][data-art="portrait"] .card-art img,
.card[data-tier="secret"][data-art="portrait"] .card-art img {
  border: 1.2cqh solid var(--navy);
  outline: .6cqh solid var(--pearl);
  background: var(--navy);
  box-shadow: 0 1.4cqh 3cqh rgb(0 0 0 / .4);
}

@keyframes foil-drift {
  0%, 100% { --mx: 18%; --my: 22%; }
  50% { --mx: 82%; --my: 74%; }
}

/* Riffling through a run: no foil, no fuss */
.card.is-riffling .card-flip { animation: riffle .16s linear infinite; }

@keyframes riffle {
  0% { transform: translateY(-5px) rotate(.5deg); }
  100% { transform: translateY(3px) rotate(-.5deg); }
}

/* Card back */

.card-back {
  display: grid;
  place-items: center;
  padding: 2.2cqh;
  background-color: var(--navy);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56'%3E%3Cpath d='M28 15c1.5 8.5 4.500 11.500 13 13-8.500 1.500-11.500 4.500-13 13-1.500-8.500-4.500-11.500-13-13 8.500-1.500 11.500-4.500 13-13Z' fill='%23f4f2ea' opacity='.13'/%3E%3C/svg%3E");
  transform: rotateY(180deg);
}

.card-back img { width: 78%; height: auto; }

.card-back::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1.6cqh solid var(--pearl);
  border-radius: inherit;
}

.card[data-heat="gold"] .card-back::before { border-color: var(--gold); }
.card[data-heat="magenta"] .card-back::before { border-color: var(--magenta); }
.card[data-heat="foil"] .card-back::before {
  border-color: transparent;
  background: var(--foil-bands) border-box;
  background-size: 200% 200%;
  mask: linear-gradient(#000 0 0) padding-box exclude, linear-gradient(#000 0 0) border-box;
}

.card.is-holding .card-back { animation: hold-shake .11s linear infinite alternate; }

@keyframes hold-shake {
  from { transform: rotateY(180deg) translateX(-2px) rotate(-.5deg); }
  to { transform: rotateY(180deg) translateX(2px) rotate(.5deg); }
}

/* Buttons */

.press-row {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 10px;
  width: min(100%, calc(var(--card-w) + 120px));
  margin-top: -4px;
}

.press {
  flex: 1 1 auto;
  min-width: 0;
  height: var(--press-h);
  border: 5px solid var(--pearl);
  border-radius: 24px;
  background: var(--navy);
  box-shadow: var(--lift);
  color: var(--pearl);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 3.5vw, 3.125rem);
  font-stretch: 150%;
  font-weight: 900;
  letter-spacing: -.01em;
  line-height: 1;
  text-transform: uppercase;
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out), background-color .12s linear;
}

.press:active { box-shadow: var(--lift-small); transform: translateY(3px); }

.press-small {
  flex: 0 0 26%;
  border-color: var(--navy);
  background: var(--pearl);
  color: var(--navy);
  font-size: clamp(1.75rem, 2.8vw, 2.375rem);
  font-stretch: 100%;
}

.press-small small {
  display: block;
  margin-top: 2px;
  font-family: var(--font-text);
  font-size: .8125rem;
  font-stretch: 100%;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

body.is-running .press:not(.press-small) { border-color: var(--navy); }

.press-small:disabled { background: var(--navy); box-shadow: none; color: rgb(244 242 234 / .5); cursor: not-allowed; }
.press-small:disabled:hover { transform: none; }
/* Held while a Mythic or dual trait plays out. */
.press:disabled:not(.press-small) { opacity: .6; cursor: wait; transform: none; }

.btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: var(--pearl);
  box-shadow: var(--lift-small);
  color: var(--navy);
  cursor: pointer;
  font: 800 1rem/1.15 var(--font-text);
  text-align: left;
  text-decoration: none;
  transition: transform .12s var(--ease-out), background-color .12s linear, color .12s linear;
}

.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { background: none; box-shadow: inset 0 0 0 1.5px var(--on-ground); color: var(--on-ground); cursor: not-allowed; opacity: .6; }

.btn.is-live { outline: 5px solid var(--pearl); outline-offset: -5px; background: var(--navy); color: var(--pearl); }

.btn-quiet {
  background: transparent;
  box-shadow: none;
  color: var(--on-ground);
  text-decoration: underline;
  text-underline-offset: .25em;
}

.switch {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 99px;
  background: rgb(11 17 71 / .22);
  transition: background-color .15s linear;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--pearl);
  transition: transform .18s var(--ease-out);
}

[aria-pressed="true"] .switch { background: var(--cobalt); }
[aria-pressed="true"] .switch::after { transform: translateX(18px); }
.btn:hover .switch { background: rgb(244 242 234 / .32); }
.btn:hover[aria-pressed="true"] .switch { background: var(--cobalt); }

.field-select {
  position: relative;
  padding-right: 0;
  cursor: pointer;
}

.field-select:has(select:focus-visible) { outline: 3px solid var(--on-ground); outline-offset: 3px; }
.field-label { flex: none; font-size: .875rem; font-weight: 700; }

.field-select select {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 38px 0 4px;
  border: 0;
  outline: 0;
  appearance: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3 6 5 5 5-5' fill='none' stroke='%230b1147' stroke-width='2.500' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 14px center / 16px no-repeat;
  color: var(--navy);
  cursor: pointer;
  font: 800 1rem var(--font-text);
  text-align: right;
}

/* The target list, where the browser lets a select be styled. Others show their own system menu. */
@supports (appearance: base-select) {
  .field-select select,
  .field-select select::picker(select) { appearance: base-select; }

  .field-select select::picker-icon { display: none; }

  .field-select select > button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: right;
  }

  selectedcontent :is(img, i, small) { display: none; }

  .field-select select::picker(select) {
    position-area: block-start span-inline-start;
    position-try-fallbacks: flip-block;
    width: min(340px, 100vw - 32px);
    max-height: calc(100dvh - 24px);
    margin-block: 8px;
    padding: 8px;
    border: 3px solid var(--navy);
    border-radius: 16px;
    background: var(--pearl);
    box-shadow: var(--lift);
    color: var(--navy);
    overflow: auto;
  }

  .field-select select:open::picker(select) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    animation: sheet-in .22s var(--ease-out);
  }

  .field-select option {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    column-gap: 8px;
    align-items: center;
    min-height: 50px;
    padding: 6px 8px;
    border-radius: 10px;
    cursor: pointer;
    font: 800 .9375rem/1.15 var(--font-text);
    text-align: left;
  }

  .field-select option::checkmark { display: none; }
  .field-select option[value=""] { grid-column: 1 / -1; }
  .field-select option small { grid-column: 2; font-size: .75rem; font-weight: 700; }
  .field-select option :is(img, i) { grid-row: span 2; width: 30px; height: 30px; }
  .field-select option:checked { background: var(--navy); color: var(--pearl); }
  .field-select option:focus-visible { outline: 3px solid var(--cobalt); outline-offset: -3px; }
  .option-foil { border-radius: 50%; background: var(--foil-bands); background-size: 200% 200%; }
  .option-none { border-radius: 50%; box-shadow: inset 0 0 0 2px currentColor; opacity: .3; }
}

/* Right column */

/* What the latest bulk run got, by rarity: a pearl slip under a caption printed on the ground like the tally. */
.haul { flex: none; width: 100%; border-collapse: separate; border-spacing: 0; border-radius: 14px; background: var(--pearl); box-shadow: var(--lift-small); color: var(--navy); font-size: .875rem; font-variant-numeric: tabular-nums; }
.haul[hidden] { display: none; }
.haul caption { padding-bottom: 6px; color: var(--on-ground); font-size: .8125rem; font-weight: 800; text-align: right; }
.haul th, .haul td { padding: 4px 12px; text-align: right; }
.haul thead th { padding-top: 9px; font-size: .6875rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; opacity: .6; }
.haul tbody th { font-weight: 700; text-align: left; }
.haul thead th:first-child { text-align: left; }
.haul td { font-weight: 800; }
.haul tbody tr:last-child > * { padding-bottom: 9px; }
/* The tier's ink as a dot, so the rare rows stand out of the list. */
.haul tbody th::before { content: ""; display: inline-block; width: .6em; height: .6em; margin-right: .5em; border-radius: 50%; background: var(--cobalt); vertical-align: .05em; }
.haul tr[data-tier="gold"] th::before { background: var(--gold); }
.haul tr[data-tier="mythic"] th::before { background: var(--magenta); }
.haul tr[data-tier="secret"] th::before { background: var(--foil-bands); }

/* The latest target run's luck, and the average kept in this browser: a pearl slip like the haul. */
.luck { flex: none; display: grid; gap: 2px; margin: 0; padding: 9px 12px; border-radius: 14px; background: var(--pearl); box-shadow: var(--lift-small); color: var(--navy); font-size: .875rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.luck[hidden], .luck [hidden] { display: none; }
#luckRun { font-weight: 800; }

.side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.tally { container-type: inline-size; color: var(--on-ground); text-align: right; }

.tally-num {
  display: block;
  font-family: var(--font-display);
  font-size: min(clamp(3.25rem, 6.4vw, 6rem), calc(100cqi / (var(--chars, 1) * .64)));
  font-stretch: 90%;
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: .95;
}

.tally-label { display: block; margin-top: 2px; font-size: .9375rem; font-weight: 800; }
.tally-pair { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; font-size: .9375rem; font-weight: 800; }
.tally-farm, .tally-cost { display: block; margin-top: 2px; font-size: .8125rem; font-weight: 700; }
/* Game currency icons. The negative margin keeps them from heightening the line. */
.tally-icon { display: inline-block; width: 1.9em; height: 1.9em; margin: -.5em .15em -.5em 0; vertical-align: middle; }
.tally-pity { display: none; margin-left: 8px; }

.log {
  --tile: 40px;
  --tile-gap: 7px;
  position: relative;
  flex: 1 1 0;
  min-height: 90px;
  overflow: auto;
  border-radius: 8px;
  scrollbar-color: var(--on-ground) transparent;
  contain: strict;
}

.log-view {
  position: absolute;
  inset: 0 0 auto;
  display: grid;
  gap: var(--tile-gap);
}

.log-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: .9375rem;
  font-weight: 800;
}

.log-empty[hidden] { display: none; }
.log-empty span { padding: 6px 12px; border-radius: 8px; background: var(--ground); }

.tile {
  display: grid;
  place-items: center;
  height: var(--tile-h);
  border-radius: 6px;
  background: var(--pearl);
  overflow: hidden;
}

.tile img { width: 76%; height: auto; }
.tile:has(img + img) { align-content: center; gap: 2px; }
.tile:has(img + img) img { width: 52%; }
.tile.is-ghost { background: none; box-shadow: inset 0 0 0 1.5px var(--on-ground); opacity: .26; }
.page-summon .tile.is-ghost { background: none; }
.tile[data-tier="gold"] { background: var(--navy); }
.tile[data-tier="mythic"], .tile[data-tier="secret"] { background: var(--foil-bands); background-size: 200% 200%; }
.page-summon .tile img { width: 100%; height: 100%; object-fit: cover; }
.page-summon .tile { padding: 2px; background: var(--navy); }
.page-summon .tile[data-tier="gold"] { background: var(--gold); }
.page-summon .tile[data-tier="mythic"], .page-summon .tile[data-tier="secret"] { background: var(--foil-bands); background-size: 200% 200%; }
/* Cut-out portraits sit on navy inside the tier frame, as the opaque ones always did. */
.page-summon .tile img { border-radius: 4px; background: var(--navy); }
.tile.is-new { animation: tile-in .24s var(--ease-out); }

@keyframes tile-in {
  from { opacity: 0; transform: scale(.6); }
  to { opacity: 1; transform: none; }
}

/* The foil bands flow on a loop. The bands repeat twice, so at 200% a corner-to-corner slide is exactly one repeat and the loop has no seam. */
.option-foil,
.tile[data-tier="mythic"],
.tile[data-tier="secret"],
.row[data-tier="secret"] .ruler i,
.card[data-heat="foil"] .card-back::before { animation: foil-flow 5s linear infinite; }
.tile.is-new:is([data-tier="mythic"], [data-tier="secret"]) { animation: tile-in .24s var(--ease-out), foil-flow 5s linear infinite; }

@keyframes foil-flow {
  to { background-position: 100% 100%; }
}

/* A sheet over the card on a phone, and ordinary page flow everywhere else. */
.controls {
  position: static;
  inset: auto;
  display: grid;
  gap: 8px;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  overflow: visible;
}

.press-adjust { display: none; }
.controls-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.controls-pair .btn { justify-content: center; padding-inline: 10px; font-size: .9375rem; text-align: center; }

.custom { --on-ground: var(--navy); display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--pearl); box-shadow: var(--lift-small); color: var(--navy); }
.custom-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.custom-label { font-size: .8125rem; font-weight: 700; }
.custom-label input {
  display: block;
  width: 100%;
  height: 40px;
  margin-top: 3px;
  padding: 0 10px;
  border: 2px solid var(--navy);
  border-radius: 9px;
  background: transparent;
  color: var(--navy);
  font: 800 1rem var(--font-text);
  font-variant-numeric: tabular-nums;
}

.custom-label input:focus-visible { outline-offset: 1px; box-shadow: none; outline-color: var(--cobalt); }

.segments { display: inline-flex; align-self: end; height: 40px; padding: 3px; border-radius: 9px; background: rgb(11 17 71 / .1); border: 0; margin: 0; min-width: 0; }
.segments label { position: relative; display: grid; place-items: center; padding-inline: 9px; border-radius: 6px; cursor: pointer; font-size: .8125rem; font-weight: 800; }
.segments input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segments label:has(input:checked) { background: var(--navy); color: var(--pearl); }
.segments label:has(input:focus-visible) { outline: 3px solid var(--cobalt); outline-offset: 1px; }

.custom .btn { min-height: 42px; justify-content: space-between; }
.custom .btn:not(:disabled) { background: var(--navy); color: var(--pearl); box-shadow: none; }
.custom-hint { font-weight: 600; font-size: .8125rem; }
.custom-error { padding: 6px 10px; border-radius: 8px; background: var(--magenta); font-size: .8125rem; font-weight: 700; }
.custom-error:empty { display: none; }

.btn-center { justify-content: center; }
.sheet-note-flat { border-top: 0; }

/* Shiny: a gold star stamped on the pull. Foil stays the Mythic and Secret prize, so shiny never uses it. */

body[data-banner="summer"] .row { --row-h: 46px; grid-template-columns: 40px minmax(0, 1fr) 4.8em; }
body[data-banner="summer"] .row-icon { width: 40px; height: 40px; }

.row-shiny,
.tile[data-shiny]::after {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6 6.6.9-4.8 4.6 1.2 6.5L12 17.4l-5.9 3.1 1.2-6.5L2.5 9.4l6.6-.9z' fill='%23ffc400' stroke='%230b1147' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.row-shiny { flex: none; width: 16px; height: 16px; }
.row-shiny[hidden] { display: none; }
.tile[data-shiny] { position: relative; }
.tile[data-shiny]::after { content: ""; position: absolute; top: 0; right: 0; width: 46%; aspect-ratio: 1; }

.shiny-line { display: flex; justify-content: space-between; gap: 8px; }

.shiny-pass {
  display: grid;
  grid-template-columns: auto 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px var(--rule);
  cursor: pointer;
}

.shiny-pass:has(input:checked) { background: var(--navy); color: var(--pearl); box-shadow: none; }
.shiny-pass input { width: 20px; height: 20px; margin: 0; accent-color: var(--gold); cursor: pointer; }
.shiny-pass img { width: 40px; height: 40px; border-radius: 9px; }
.shiny-pass b { display: block; font-size: .9375rem; font-weight: 800; line-height: 1.15; }
.shiny-pass small { display: block; font-size: .75rem; font-weight: 600; }

.card[data-shiny] .card-art::after {
  content: "\2605  Shiny";
  position: absolute;
  top: 1.4cqh;
  left: 1.4cqh;
  z-index: 2;
  padding: .6cqh 1.4cqh;
  border: .4cqh solid var(--navy);
  border-radius: 99px;
  background: var(--gold);
  color: var(--navy);
  font: 900 max(.75rem, 2.4cqh)/1 var(--font-display);
  text-transform: uppercase;
}

/* A gloss sweeps the art now and then. */
.card[data-shiny] .card-art::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(115deg, transparent 38%, rgb(255 255 255 / .6) 48%, rgb(255 236 170 / .35) 53%, transparent 62%) 100% 0 / 250% 100% no-repeat;
  animation: shiny-sweep 2.8s var(--ease-out) infinite;
  pointer-events: none;
}

@keyframes shiny-sweep {
  0%, 35% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* Share sticker and poster */

.sticker {
  position: absolute;
  top: 12cqh;
  right: -16px;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1px;
  width: 62px;
  height: 62px;
  padding: 0;
  border: 3px solid var(--navy);
  border-radius: 50%;
  background: var(--pearl);
  box-shadow: var(--lift-small);
  color: var(--navy);
  cursor: pointer;
  font: 800 .75rem/1 var(--font-text);
  rotate: 8deg;
  animation: sticker-in .32s var(--ease-out);
}

.sticker[hidden] { display: none; }
.sticker svg { display: block; }
.sticker:active { scale: .94; }
.sticker:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; box-shadow: 0 0 0 2px var(--pearl); }

@keyframes sticker-in {
  from { opacity: 0; rotate: -24deg; scale: .5; }
}

.share {
  --ground: var(--pearl);
  --on-ground: var(--navy);
  width: min(100vw - 24px, 440px);
  max-width: none;
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--pearl);
  box-shadow: var(--lift);
  color: var(--navy);
}

.share::backdrop { background: rgb(11 17 71 / .72); }
html:has(.share[open]) { overflow: hidden; }

.share-body { display: grid; gap: 8px; padding: 12px; }
.share-poster { width: min(100%, (100dvh - 200px) * .8); height: auto; aspect-ratio: 4 / 5; margin-inline: auto; border-radius: 8px; background: rgb(11 17 71 / .07); }
.share-status { font-weight: 700; text-align: center; }
.share-status:empty { display: none; }
.share-actions { display: flex; gap: 8px; }
.share-actions[hidden], .share-actions [hidden] { display: none; }
.share-actions .btn { flex: 1; min-width: 0; background: var(--navy); box-shadow: none; color: var(--pearl); }

/* Touch has no hover, so a tapped control must not stay in its hover colour. Last, so each state overrides its base. */
@media (hover: hover) {
  .press:hover { background: var(--cobalt); transform: translateY(-2px); }
  .press-small:hover { background: var(--pearl); }
  .btn:hover:not(:disabled) { background: var(--navy); color: var(--pearl); }
  .field-select:hover:not(:disabled) { background: var(--pearl); color: var(--navy); }
  .btn-quiet:hover:not(:disabled) { background: var(--on-ground); color: var(--ground); }
  .custom .btn:hover:not(:disabled), .share-actions .btn:hover { background: var(--cobalt); color: var(--pearl); }
  .sticker:hover { background: var(--navy); color: var(--pearl); }
  .field-select option:hover:not(:checked) { background: rgb(11 17 71 / .1); }
}

/* Home and banner picker */

.page-home { overflow-x: hidden; }

.lobby {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
  align-items: center;
  gap: clamp(16px, 3vw, 48px);
  min-height: calc(100dvh - var(--strip-h, 0px));
  padding: clamp(16px, 3vh, 36px) clamp(16px, 4vw, 64px);
  isolation: isolate;
  overflow: hidden;
}

.lobby-rings { position: absolute; top: 50%; left: 68%; z-index: -1; transform: translate(-50%, -50%); }
.lobby-rings i { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); }
.lobby-rings i:first-child { width: min(140vh, 84vw); aspect-ratio: 1; background: var(--magenta); }
.lobby-rings i:last-child { width: min(106vh, 64vw); aspect-ratio: 1; background: var(--gold); }

.lobby-intro { display: grid; gap: clamp(16px, 3vh, 28px); justify-items: start; }
.lobby-logo { width: min(100%, 560px); }
.lobby-logo img { width: 100%; height: auto; }
.lobby-heading { font-family: var(--font-display); font-size: clamp(2rem, 3.4vw, 3.25rem); font-stretch: 125%; font-weight: 900; letter-spacing: -.02em; line-height: 1; }

.lobby .credit { padding: 0; text-align: left; font-size: .9375rem; }

/* The stat check is a tool, not a pull, so it sits under the logo as a pearl ticket instead of a pack. */
/* The stat check is a tool, not a pull, so it sits under the packs as a dark Stat Cube ticket instead of a pack.
   It wears the game's own look: a rarity rim and three graded stat chips with their % hidden. */
.lobby { align-content: center; }
.lobby-intro { grid-row: span 2; }
.stat-ticket {
  grid-column: 2;
  justify-self: center;
  position: relative; /* no stacking context of its own, so the rim plate below can sit under its background */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  width: min(100%, 780px);
  margin: 4px;
  padding: 22px 46px 14px 20px; /* the top clears the New stamp */
  border-radius: 16px;
  background: #121212;
  color: #fff;
  text-decoration: none;
}
.stat-ticket::before {
  content: "";
  position: absolute;
  inset: -4px;
  z-index: -1;
  border-radius: 20px;
  background: linear-gradient(135deg, #4fe3ff, #a46bff, #ff4fb4, #ffd23f);
  box-shadow: var(--lift-small);
  transition: inset .14s var(--ease-out);
}
.stat-ticket:focus-visible { outline-offset: 8px; }
.tk-head { display: grid; gap: 4px; flex: 1 1 200px; min-width: 0; }
.tk-head b { font: 900 1.375rem/1 var(--font-display); font-stretch: 112%; letter-spacing: -.01em; }
.tk-head small { color: #c4c4c4; font-size: .875rem; font-weight: 700; line-height: 1.3; }
.tk-chips { display: grid; flex: 0 1 390px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tk-chip {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 4px 6px;
  padding: 8px 10px 9px;
  border: 2px solid #2a2a2a;
  border-radius: 9px;
  background: #1d1d1d;
}
.tk-icon { width: 26px; height: 26px; }
.tk-grade { font: 900 1.875rem/1 var(--font-text); letter-spacing: -.02em; text-align: right; white-space: nowrap; }
.tk-pct { grid-column: 1 / -1; font: 900 1.0625rem/1 var(--font-text); text-align: right; white-space: nowrap; }
.tk-arrow { position: absolute; top: 50%; right: 16px; width: 20px; height: 20px; transform: translateY(-50%); }
/* "New" stamp on the corner, and a light sweep across the ticket, so the new tool gets noticed (owner, 2026-11-12). */
.tk-new {
  position: absolute;
  top: -17px;
  left: 14px;
  padding: 6px 14px 5px;
  border: 2.5px solid var(--navy);
  border-radius: 99px;
  background: var(--gold);
  color: var(--navy);
  font: 900 1rem/1 var(--font-display);
  letter-spacing: .04em;
  text-transform: uppercase;
  transform: rotate(-6deg);
}
.stat-ticket::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(105deg, transparent 42%, rgb(255 255 255 / .13) 50%, transparent 58%) 160% 0 / 250% 100% no-repeat;
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .tk-new { animation: tk-new-wiggle 3.6s var(--ease-out) infinite; }
  .stat-ticket::after { animation: tk-shine 3.6s ease-in-out infinite; }
}
@keyframes tk-new-wiggle {
  0%, 78%, 100% { transform: rotate(-6deg) scale(1); }
  83% { transform: rotate(-13deg) scale(1.16); }
  88% { transform: rotate(2deg) scale(1.1); }
  93% { transform: rotate(-9deg) scale(1.03); }
}
@keyframes tk-shine {
  0%, 55% { background-position: 160% 0; }
  85%, 100% { background-position: -60% 0; }
}

/* The rim swells on hover; a transform would give the ticket a stacking context and lift the rim over it. */
@media (hover: hover) { .stat-ticket:hover::before { inset: -7px; } }

/* Grade ink as the game prints it (owner's screenshots): C-, C+, B-, B, S, SS and SSS read off them; A is between. */
[data-grade="Cm"] { color: #ff4a3d; }
[data-grade="C"] { color: #e8382e; }
[data-grade="Cp"] { color: #c8291f; }
[data-grade="Bm"] { color: #ffe44a; }
[data-grade="B"] { color: #eef86a; }
[data-grade="Bp"] { color: #c9f25a; }
[data-grade^="A"] { color: #7ef07a; }
[data-grade="Sm"], [data-grade="S"], [data-grade="Sp"] { color: #5ef0c4; }
[data-grade="SS"] { color: #5ee4f2; }
[data-grade="SSS"] {
  background: linear-gradient(90deg, #d946ef, #ff5fa2 55%, #ff9a3c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.packs {
  --pack-w: min(calc((100dvh - 88px - 132px - var(--strip-h, 0px)) * .6), 420px, calc(33vw - 48px)); /* 132px: the stat ticket under them */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 32px);
}

.pack {
  --rest: -4deg;
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  flex: none;
  width: var(--pack-w);
  height: calc(var(--pack-w) / .6);
  border-radius: 8px;
  color: var(--pearl);
  filter: drop-shadow(0 28px 34px rgb(0 0 0 / .32));
  text-decoration: none;
  transform: rotate(var(--rest)) perspective(1200px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform .32s var(--ease-out);
  container-type: size;
}

.pack-summon { --film: url("images/pack-film-navy.webp"); view-transition-name: pack-summon; }
.pack-reroll { --film: url("images/pack-film-pearl.webp"); --rest: 3.5deg; margin-top: 2.5vh; view-transition-name: pack-reroll; color: var(--navy); }
.pack:hover { transform: translateY(-1.5%) rotate(calc(var(--rest) * .3)) perspective(1200px) rotateX(var(--rx)) rotateY(var(--ry)); }
.pack.is-tracking { transition: transform .06s linear; }

.pack-body {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 11cqh 5.4cqh 9cqh;
  background: var(--navy);
  mask: var(--film) center / 100% 100% no-repeat;
}

.pack-reroll .pack-body { background: var(--pearl); }

/* The film lies over the print: its 50% grey leaves ink alone, lighter reflects, darker creases. */
.pack-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--film) center / 100% 100% no-repeat;
  mix-blend-mode: hard-light;
  pointer-events: none;
}

.pack-art {
  position: relative;
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin-block: 2.4cqh;
}

.pack-art > img {
  position: relative;
  width: min(100%, 34cqh);
  max-height: 100%;
  aspect-ratio: 1;
  border-radius: 2.4cqh;
  object-fit: cover;
}

.pack-summon .pack-art::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 45cqh;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--magenta);
  transform: translate(-50%, -50%);
}

.pack-grid { display: grid; grid-template: repeat(4, minmax(0, 1fr)) / repeat(3, minmax(0, 1fr)); gap: 1.6cqh; height: 100%; aspect-ratio: 3 / 4; }
.pack-grid img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }

.pack-title {
  position: relative;
  font-family: var(--font-display);
  font-size: 8.4cqh;
  font-stretch: 112%;
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: .96;
}

.pack-title-long { font-size: 7cqh; }
.pack-title img { display: inline-block; width: .9em; height: auto; margin-left: .12em; vertical-align: -.06em; }

/* The banner that is live in the game now, stamped like the shiny chip. */
.pack-badge {
  position: relative;
  z-index: 1;
  align-self: flex-start;
  padding: .8cqh 1.8cqh;
  border: .4cqh solid var(--navy);
  border-radius: 99px;
  background: var(--gold);
  color: var(--navy);
  font: 900 max(.6875rem, 2.3cqh)/1 var(--font-display);
  text-transform: uppercase;
  white-space: nowrap;
}

.pack-meta { position: relative; margin-top: 1.6cqh; padding-top: 1.4cqh; border-top: 2px solid currentColor; font-size: max(.8125rem, 2.3cqh); font-weight: 700; line-height: 1.3; }

.pack:focus-visible { outline-offset: 6px; }

.lobby-back { width: auto; min-width: 200px; justify-content: center; }

/* Tablet: card and controls side by side, checklist below */

@media (max-width: 1100px) {
  .sim {
    --card-h: min(calc(100dvh - 84px - var(--strip-h, 0px) - 44px - var(--press-h)), 620px);
    grid-template-areas: "stage side" "checklist checklist";
    grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
    height: auto;
    min-height: 0;
  }

  .press { box-shadow: var(--lift-small); }
  .stage { min-height: calc(var(--card-h) + var(--press-h) + 16px); }
  .side { max-height: calc(var(--card-h) + var(--press-h) + 16px); }
  .sheet { max-height: none; }
  .page-reroll #checklist { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
  .page-reroll .row { --row-h: 44px; }
}

/* Phone: card first, Reroll pinned under the thumb */

@media (max-width: 760px) {
  .top { height: 64px; }
  .top-logo img { height: 50px; }
  .tab { padding: .5em .75em; font-size: .875rem; }
  /* Four tabs and the logo overflow a narrow phone. The logo already leads to the menu, so the Menu tab steps aside. */
  @media (max-width: 420px) {
    .top-logo img { height: 44px; }
    .tab { padding: .5em .6em; font-size: .8125rem; }
    .tab-menu { display: none; }
  }

  .credit { padding: 4px 16px 132px; }
  .page-home .credit { padding: 0; }

  .sim {
    --tally-h: 92px;
    --avail-h: calc(100dvh - 64px - var(--strip-h, 0px) - var(--tally-h) - 124px);
    --card-w: min(calc(100vw - 44px), calc(var(--avail-h) * .669), 400px);
    --card-h: calc(var(--card-w) / .669);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 0 16px 24px;
  }

  /* The trait tally carries two more lines: token cost and farm time. It measures 121px; 124 keeps the card clear of the pinned Reroll. */
  .page-reroll .sim { --tally-h: 124px; }

  .side { display: contents; }

  .tally { order: -1; display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
  .tally-num { font-size: min(2.75rem, calc(58cqi / (var(--chars, 1) * .64))); }
  .tally-label { margin-top: 0; }
  .tally-pair, .tally-farm, .tally-cost { flex-basis: 100%; margin-top: 0; }
  .tally-pity { display: inline; }

  .stage { order: 0; min-height: calc(100dvh - 64px - var(--strip-h, 0px) - var(--tally-h) - 14px); padding-bottom: 112px; }
  .card { --rest: -1.5deg; }
  .halo { top: calc(50% - 56px); width: calc(var(--card-h) * 1.14); }
  /* The card covers the burst on a phone, so Secret lands on the same clean disc as Mythic. */
  body[data-ink="foil"] .halo { background: var(--gold); }
  body[data-ink="foil"] .halo::before { display: none; }

  .press-row {
    position: fixed;
    right: 16px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 16px;
    z-index: 10;
    width: auto;
    margin: 0;
  }

  .press { height: 88px; padding-inline: 0; font-size: clamp(2rem, 11vw, 3rem); }
  /* REROLL shares this row with two fixed buttons, so it narrows to stay tall, and its size follows the room left. */
  .page-summon .press { font-size: min(2.5rem, (100vw - 198px) / 5.5); font-stretch: 125%; }
  .page-summon .press-small { flex-basis: 72px; font-size: 1.75rem; font-stretch: 100%; }
  .press-row .press-adjust { flex-basis: 60px; }
  .press-adjust svg { display: block; margin-inline: auto; }

  .controls { order: 1; }
  /* A short phone's card can't fit a dual trait's four effect lines and the note, so the art keeps that room. */
  @media (max-height: 700px) { .card[data-art="pair"] .card-note { display: none; } }

  /* The list takes the control sheet's place, above the thumb. */
  @supports (appearance: base-select) {
    .field-select select::picker(select) {
      position-area: none;
      position: fixed;
      inset: auto 16px calc(110px + env(safe-area-inset-bottom));
      width: auto;
      max-height: calc(100dvh - 130px - env(safe-area-inset-bottom));
      margin: 0;
      box-shadow: var(--lift-small);
    }
  }

  /* The controls lift over the card, so nothing needs a scroll. Older browsers keep them in the page below. */
  @supports selector(:popover-open) {
    .press-row .press-adjust { display: block; }
    body:has(.controls:popover-open) .press-adjust { border-color: var(--pearl); background: var(--navy); color: var(--pearl); }

    .controls {
      --ground: var(--pearl);
      --on-ground: var(--navy);
      position: fixed;
      inset: auto 16px calc(110px + env(safe-area-inset-bottom));
      max-height: calc(100dvh - 130px - env(safe-area-inset-bottom));
      padding: 12px;
      border: 3px solid var(--navy);
      border-radius: 16px;
      background: var(--pearl);
      box-shadow: var(--lift-small);
      color: var(--navy);
      overflow: auto;
    }

    /* One surface: everything in the sheet prints flat on it. */
    .custom { padding: 0; background: none; box-shadow: none; }
    .controls .btn:not(.btn-quiet, .field-select, :disabled) { background: var(--navy); box-shadow: none; color: var(--pearl); }
    .controls .field-select { background: none; box-shadow: inset 0 0 0 2px var(--navy); }

    .controls:popover-open { animation: sheet-in .22s var(--ease-out); }
    .controls:not(:popover-open) { display: none; }
  }
  .sheet { order: 2; align-self: stretch; }
  .page-reroll #checklist { display: block; }
  .log { order: 3; flex: none; height: 260px; }
  .haul, .luck { order: 1; }

  .lobby { grid-template-columns: minmax(0, 1fr); align-content: center; justify-items: center; gap: 18px; padding-block: 18px; }
  .lobby-intro { display: contents; }
  .lobby-logo { width: min(70vw, 280px); }
  .lobby-heading { color: var(--navy); text-align: center; }
  .packs { order: 1; }
  .lobby-back { order: 2; }
  .lobby-intro { grid-row: auto; }
  .stat-ticket { order: 2; grid-column: auto; width: calc(100% - 8px); padding-right: 16px; }
  .tk-head { padding-right: 30px; }
  .tk-chip { grid-template-columns: 18px minmax(0, 1fr); padding-inline: 8px; }
  .tk-icon { width: 18px; height: 18px; }
  .tk-grade { font-size: clamp(1.125rem, 5.8vw, 1.75rem); }
  .tk-chips { flex-basis: 100%; }
  .tk-arrow { top: 22px; transform: none; }
  .lobby .credit { order: 3; padding: 6px 14px; border-radius: 12px; background: var(--pearl); color: var(--navy); text-align: center; }
  .lobby-rings { top: 60%; left: 50%; }
  .lobby-rings i:first-child { width: 190vw; }
  .lobby-rings i:last-child { width: 120vw; }

  .packs { --pack-w: min(calc((100dvh - 330px - var(--strip-h, 0px)) * .6), calc((100vw - 44px) / 2)); width: 100%; }
  .pack-reroll { margin-top: 1.5vh; }
  .pack-body { padding-inline: 5cqh; }
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(16px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }

  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* Ad slots. An empty slot is a placement frame, shown only in preview (a local server, or ?ads in the address).
   Once it holds a real AdSense unit it shows on the live site at the same size and breakpoints. */

.ad-slot { display: grid; flex: none; place-content: center; margin-inline: auto; }
html:not(.ad-preview) .ad-slot:empty { display: none; }

.ad-slot:empty {
  border: 2px dashed color-mix(in srgb, var(--on-ground) 75%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--on-ground) 12%, transparent);
  color: var(--on-ground);
  font-size: .8125rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.ad-slot:empty::before { content: attr(data-ad); white-space: pre-line; }

.ad-side { width: 100%; height: 250px; }
.ad-lobby { width: 300px; height: 250px; margin-inline: 0; }
.ad-bottom { width: min(728px, 100% - 32px); height: 90px; margin-block: 8px 32px; }

/* The top strip is its own band above everything: a 728 × 90 leaderboard, 320 × 50 on a phone.
   Every layout that fills the screen subtracts --strip-h, so the card and Reroll still fit without a scroll. */
html.ad-preview:has(.ad-strip), html:has(.ad-strip:not(:empty)) { --strip-h: 106px; }
.ad-strip { width: 100%; height: var(--strip-h); background: rgb(11 17 71 / 0.35); }
.ad-strip:empty { border: 0; border-radius: 0; background: rgb(11 17 71 / 0.35); }
.ad-strip:empty::before {
  display: grid;
  place-content: center;
  width: 728px;
  height: 90px;
  box-sizing: border-box;
  border: 2px dashed color-mix(in srgb, var(--on-ground) 75%, transparent);
  border-radius: 8px;
}

/* The sidebar rectangle takes room from the pull log, so only a desktop screen tall enough for it and the strip gets it. */
@media (max-width: 1100px), (max-height: 1045px) { .ad-side { display: none; } }
@media (max-width: 1100px) { .ad-lobby { display: none; } }

/* Phone: the strip narrows to 320 × 50, and the end rectangle grows to 300 × 250. */
@media (max-width: 760px) {
  html.ad-preview:has(.ad-strip), html:has(.ad-strip:not(:empty)) { --strip-h: 62px; }
  .ad-strip:empty::before { width: 320px; height: 50px; }
  .ad-bottom { width: 300px; height: 250px; margin-block: 8px 24px; }
}

/* Five tabs don't fit beside the logo on a narrow phone, so the tab row scrolls sideways there. */
@media (max-width: 520px) {
  .top nav { display: flex; gap: inherit; min-width: 0; overflow-x: auto; scrollbar-width: none; padding-block: 4px; }
}
