/* Art Lab: the pack opening, the card deck and the "All pieces" list.
   Cyber Yellow & Obsidian: flat fills, crisp lines, hard shadows.
   Tokens and fonts come from ../assets/css/variables.css and fonts.css.
   Animations move only transform and opacity. */

:root {
  --text: var(--text-primary);
  --text-2: var(--text-secondary);
  --text-3: var(--text-muted);
  --bar-h: 52px;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); }

body {
  min-height: 100%;
  font-family: var(--font-main);
  color: var(--text);
  background-color: var(--bg);
  /* the hub's faint pixel grid */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Crect width='2' height='2' fill='%23facc15' fill-opacity='.07'/%3E%3C/svg%3E");
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* The opening and the deck fill the screen; the list scrolls. */
html[data-view="opening"], html[data-view="deck"],
html[data-view="opening"] body, html[data-view="deck"] body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }

:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 3px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: 8px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--primary);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-md);
  transform: translateY(-160%);
}
.skip-link:focus-visible { transform: none; }

/* ---------- Views ---------- */
.view { display: none; }
html:not([data-view]) .view-grid,
html[data-view="grid"] .view-grid { display: block; }
html[data-view="opening"] .view-opening { display: block; }
html[data-view="deck"] .view-deck,
html.is-handoff .view-deck { display: grid; }
html.is-handoff .view-deck { opacity: 0; pointer-events: none; }
html.is-handoff .view-opening { z-index: 2; }
html:not([data-view]) .js-only { display: none; }

/* ---------- Top bar ---------- */
.bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: var(--bar-h);
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.bar-title {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
}
.bar-title b { color: var(--primary); }
.bar-title span { color: var(--text-3); font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

.nav-icons-group { display: flex; align-items: center; gap: 8px; flex: none; }

.icon-btn,
.bar .corner-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: border-color 0.08s, transform 0.08s, box-shadow 0.08s;
}
/* Hover lifts only where there is real hover (touch would leave it stuck). */
@media (hover: hover) {
  .icon-btn:hover,
  .bar .corner-link:hover { border-color: var(--primary); transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--primary); }
  .btn:hover { border-color: var(--primary); transform: translate(-2px, -2px); box-shadow: 4px 4px 0 #000; }
  .btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); box-shadow: 6px 6px 0 #000; }
  .pip:hover { border-color: var(--primary); color: var(--text); }
  .fan.is-fanned .slot:hover .card { transform: translateY(-7%); }
  .fan.is-fanned .slot:hover { z-index: 20 !important; }
  .fan.is-fanned .slot.is-next:hover .card { animation: none; }
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
.icon-btn .fab, .bar .corner-link .fas { font-size: 16px; }
.icon-btn[aria-pressed="true"] { background: var(--primary); color: var(--ink); border-color: var(--primary); }
.icon-btn .lbl { display: none; }
.icon-btn--text { padding: 0 12px; border-color: var(--primary); color: var(--primary); }
.icon-btn--text svg { width: 14px; height: 14px; }

@media (min-width: 760px) { .icon-btn .lbl { display: inline; } }
@media (max-width: 560px) { .bar-title span { display: none; } }
@media (max-width: 480px) {
  .wide-only { display: none; }
  .bar { gap: 6px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .nav-icons-group { gap: 6px; }
}
@media (max-width: 340px) {
  .icon-btn, .bar .corner-link { min-width: 36px; height: 38px; padding: 0 8px; }
  .icon-btn--text { padding: 0 9px; }
  .bar-title { font-size: 14px; }
}
/* With the music player in the bar, the narrowest phones keep the icons and drop the title */
@media (max-width: 359px) { .bar-title { display: none; } .bar .nav-icons-group { margin-left: auto; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.08s, box-shadow 0.08s, background-color 0.08s, border-color 0.08s;
}
.btn:active { transform: none; box-shadow: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--ink); box-shadow: 4px 4px 0 #000; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: square; }
.btn[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }

.chip {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* ---------- Card ----------
   .card         sized box (--cw), 5:7 portrait; sizes inside use cqw
   .card-lift    tilt layer
   .card-inner   flip layer (rotateY)
   .card-face    front / back */
.card {
  position: relative;
  width: var(--cw, 220px);
  aspect-ratio: 5 / 7;
  container-type: inline-size;
  perspective: 1100px;
}
.card-lift, .card-inner { position: absolute; inset: 0; transform-style: preserve-3d; }
.card-inner { transform: rotateY(0deg); }
.card.is-down .card-inner { transform: rotateY(180deg); }

/* Cards that never flip stay flat: far cheaper to composite. */
.card.is-flat { perspective: none; }
.card.is-flat .card-lift, .card.is-flat .card-inner { transform-style: flat; }

.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 4.5cqw;
  border: max(1px, 0.9cqw) solid #34353f;
  background: var(--surface);
  box-shadow: 3cqw 3cqw 0 #000;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.card-back { transform: rotateY(180deg); box-shadow: -3cqw 3cqw 0 #000; }

.card-front { display: flex; flex-direction: column; padding: 4.5cqw; gap: 2.6cqw; }
.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 6.4cqw;
  line-height: 1;
  letter-spacing: 0.04em;
}
.card-no { color: var(--primary); }
.card-no small { font-size: 0.75em; color: var(--text-3); }
.card-tech {
  padding: 1.2cqw 2.4cqw;
  border-radius: 1.6cqw;
  background: var(--primary);
  color: var(--ink);
  font-size: 0.78em;
  text-transform: uppercase;
}
.card-art {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 2.4cqw;
  border: max(1px, 0.6cqw) solid #000;
  background: #000;
}
.card-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 7.8cqw;
  line-height: 1.05;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-tags {
  font-size: 4.8cqw;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: max(1px, 0.5cqw) solid var(--line);
  padding-top: 2.6cqw;
  font-size: 4.4cqw;
  line-height: 1.2;
}
.card-stats div { min-width: 0; }
.card-stats dt { color: var(--text-3); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.9em; }
.card-stats dd { font-family: var(--font-display); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pips { color: var(--primary); letter-spacing: 0.1em; }

@container (max-width: 150px) {
  .card-stats, .card-tags { display: none; }
  .card-front { gap: 3.4cqw; }
  .card-title { font-size: 8.6cqw; }
}

/* Specular sheen: one soft white band, moved by transform. */
.card-sheen {
  position: absolute;
  inset: -20% -60%;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, 0.16) 49%, rgba(255, 255, 255, 0.04) 53%, transparent 58%);
  transform: translateX(var(--sheen-x, -40%));
  opacity: 0;
  transition: opacity 0.2s;
}
.card.is-lit .card-sheen { opacity: 1; }

/* Rarity: a holo card has a fine scanline screen and an amber frame. */
.card[data-rarity="3"] .card-front::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 3px);
  opacity: 0.55;
}
.card[data-rarity="3"] .card-face.card-front { border-color: var(--primary-dark); }
.card[data-rarity="2"] .card-face.card-front { border-color: #5b5d6b; }

/* Back: a crisp pixel checker, a yellow frame and the lab mark. */
.card-back {
  background-color: #0e0f14;
  background-image: repeating-conic-gradient(rgba(250, 204, 21, 0.09) 0 25%, transparent 0 50%);
  background-size: 6cqw 6cqw;
  display: grid;
  place-items: center;
}
.card-back::before {
  content: '';
  position: absolute;
  inset: 5cqw;
  border: max(1px, 0.9cqw) solid var(--primary);
  border-radius: 2.4cqw;
}
.back-mark {
  position: relative;
  display: grid;
  place-items: center;
  gap: 4cqw;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--primary);
  text-align: center;
}
.back-mark i {
  display: grid;
  place-items: center;
  width: 26cqw;
  height: 26cqw;
  background: var(--primary);
  color: var(--ink);
  transform: rotate(45deg);
  box-shadow: 2cqw 2cqw 0 #000;
  font-style: normal;
}
.back-mark i span { transform: rotate(-45deg); font-size: 9cqw; letter-spacing: -0.02em; }
.back-mark b { font-size: 7cqw; letter-spacing: 0.24em; padding: 1.5cqw 3cqw; background: #0e0f14; }

/* =====================================================================
   Opening: the booster pack
   ===================================================================== */
.opening {
  position: fixed;
  inset: var(--bar-h) 0 0 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.pack {
  --pw: min(280px, 62vw, calc((100dvh - var(--bar-h) - 120px) / 1.5));
  position: absolute;
  left: 50%;
  top: calc(50% - 26px);
  width: var(--pw);
  height: calc(var(--pw) * 1.5);
  margin: calc(var(--pw) * -0.75) 0 0 calc(var(--pw) / -2);
  z-index: 3;
}
.pack.is-gone { visibility: hidden; }
.pack-shadow { position: absolute; inset: 0; background: #000; transform: translate(9px, 9px); }
.pack-half { position: absolute; left: 0; right: 0; overflow: hidden; }
.pack-top { top: 0; height: 17%; z-index: 2; transform-origin: 100% 100%; }
.pack-body { top: 0; bottom: 0; z-index: 1; }

/* Each half carries the full-size skin; clip-path decides what it shows. */
.pack-skin {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--pw);
  height: calc(var(--pw) * 1.5);
  background: #15161d;
  overflow: hidden;
}
.pack-body .pack-skin {
  display: flex;
  flex-direction: column;
  padding: calc(var(--pw) * 0.31) calc(var(--pw) * 0.08) calc(var(--pw) * 0.15);
  gap: calc(var(--pw) * 0.035);
  border-left: 3px solid var(--primary);
}
.crimp {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: calc(var(--pw) * 0.11);
  background: #1f2129 repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.09) 0 2px, transparent 2px 6px);
  border-bottom: 2px solid #000;
}
.crimp-bottom { top: auto; bottom: 0; border-bottom: 0; border-top: 2px solid #000; }
.pack-head { display: flex; justify-content: space-between; align-items: center; }
.pack-series, .pack-count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: calc(var(--pw) * 0.048);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.pack-series { background: var(--primary); color: var(--ink); padding: 0.25em 0.6em; border-radius: 3px; }
.pack-count { color: var(--text-2); }
.pack-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: calc(var(--pw) * 0.25);
  line-height: 0.84;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--primary);
  text-shadow: calc(var(--pw) * 0.018) calc(var(--pw) * 0.018) 0 #000;
}
.pack-sub {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: calc(var(--pw) * 0.046);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-2);
}
.pack-window {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: calc(var(--pw) * 0.02) calc(var(--pw) * -0.08);
  overflow: hidden;
}
.pack-strip {
  position: absolute;
  left: -10%;
  top: 50%;
  display: flex;
  gap: 6px;
  height: 78%;
  padding: 4px 0;
  background: var(--primary);
  transform: translateY(-50%) rotate(-9deg);
}
.pack-strip img { height: 100%; width: auto; aspect-ratio: 16 / 10; object-fit: cover; display: block; border: 2px solid #000; }
.pack-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: calc(var(--pw) * 0.042);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
}
.barcode {
  width: 34%;
  height: calc(var(--pw) * 0.07);
  background: repeating-linear-gradient(90deg, #e8e8e8 0 2px, transparent 2px 4px, #e8e8e8 4px 5px, transparent 5px 8px, #e8e8e8 8px 11px, transparent 11px 13px);
}

/* Foil sheen: a white band that follows a mouse, and idles across on its own. */
.pack-sheen {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--pw);
  height: calc(var(--pw) * 1.5);
  pointer-events: none;
  overflow: hidden;
}
.pack-sheen::before {
  content: '';
  position: absolute;
  inset: -10% -100%;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 3px),
    linear-gradient(100deg, transparent 44%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.05) 54%, transparent 60%);
  -webkit-mask: linear-gradient(100deg, transparent 40%, #000 50%, transparent 62%);
  mask: linear-gradient(100deg, transparent 40%, #000 50%, transparent 62%);
  transform: translateX(var(--sx, -30%));
}
.pack.is-idle .pack-sheen::before { animation: sheen-idle 4.5s cubic-bezier(.5, 0, .5, 1) infinite; }
@keyframes sheen-idle {
  0%, 30% { transform: translateX(-34%); }
  70%, 100% { transform: translateX(34%); }
}

.tear-guide { position: absolute; left: 0; right: 0; top: 17%; height: 0; z-index: 4; pointer-events: none; }
.tear-guide::before {
  content: '';
  position: absolute;
  left: 4%;
  right: 4%;
  top: -1px;
  border-top: 2px dashed rgba(250, 204, 21, 0.55);
}
.tear-progress {
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  height: 4px;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: 0 50%;
}
.tear-hint {
  position: absolute;
  right: -6px;
  top: -13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--primary);
  color: var(--ink);
  box-shadow: 3px 3px 0 #000;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transform: translateX(50%);
}
.tear-hint svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; animation: nudge 1.1s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(3px); } }
.pack.is-torn .tear-guide { opacity: 0; transition: opacity 0.15s; }
@media (max-width: 420px) { .tear-hint { right: 4px; transform: none; } }

.pack-hit {
  position: absolute;
  inset: -12px;
  z-index: 5;
  cursor: grab;
  touch-action: none;
  border-radius: 6px;
}
.pack-hit:active { cursor: grabbing; }

/* The fan of cards */
.fan { position: absolute; left: 50%; top: 0; width: 0; height: 0; z-index: 2; }
.slot {
  position: absolute;
  left: calc(var(--cw) / -2);
  top: calc(var(--cw) * -0.7);
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  visibility: hidden;
}
.fan.is-live .slot { visibility: visible; }
.slot .card { transition: transform 0.16s var(--ease-out); }
.fan.is-fanned .slot:focus-within .card { transform: translateY(-7%); }
.fan.is-fanned .slot:focus-within { z-index: 20 !important; }
.slot-btn { position: absolute; inset: 0; z-index: 2; border-radius: 8px; }
.slot-btn:disabled { cursor: default; }
.slot.is-next .card { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4%); } }

/* Reveal flash for uncommon and holo cards: a yellow frame snaps in and fades. */
.slot .flash {
  position: absolute;
  inset: -6px;
  border: 3px solid var(--primary);
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
}

.hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hint {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  text-align: center;
}
.hint b { color: var(--primary); }
.hud-actions { display: flex; gap: 10px; }
.stamp {
  display: flex;
  white-space: nowrap;
  align-items: baseline;
  gap: 10px;
  padding: 6px 14px;
  background: var(--primary);
  color: var(--ink);
  border: 2px solid #000;
  box-shadow: 5px 5px 0 #000;
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transform: rotate(-4deg);
}
.stamp b { font-size: 16px; }
.stamp span { font-size: 13px; }

@media (max-height: 480px) and (orientation: landscape) {
  .hint { font-size: 11px; padding: 4px 8px; }
  .hud { bottom: 6px; gap: 6px; }
  .hud .btn { min-height: 36px; }
}

/* =====================================================================
   Deck: the living stack
   ===================================================================== */
.browser {
  position: fixed;
  inset: var(--bar-h) 0 0 0;
  grid-template-areas: "card info" "pips info";
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0 clamp(16px, 4vw, 56px);
  padding: 16px clamp(16px, 5vw, 72px) max(16px, env(safe-area-inset-bottom));
  user-select: none;
  -webkit-user-select: none;
}
.card-area { grid-area: card; position: relative; display: grid; place-items: center; min-height: 0; }

.stack {
  position: relative;
  width: var(--cw, 300px);
  height: calc(var(--cw, 300px) * 1.4);
  touch-action: none;
  border-radius: 4.5%;
}
.stack:focus-visible { outline-offset: 8px; }

.scard { position: absolute; inset: 0; transform-origin: 50% 100%; }
.scard .card { --cw: 100%; width: 100%; }
.scard.is-top { cursor: grab; }
.scard.is-top:active { cursor: grabbing; }
.scard .card-art img { transform: scale(1.14); }
/* The top card is alive: its art drifts and a glint passes now and then.
   Both are CSS animations, so they run on the compositor. */
.scard.is-top .card-art img { animation: drift 12s ease-in-out infinite alternate; }
.scard.is-top .card-sheen { opacity: 1; animation: glint 7s cubic-bezier(.5, 0, .3, 1) 1s infinite; }
@keyframes drift {
  0% { transform: translate(-3%, -2%) scale(1.14); }
  50% { transform: translate(2.6%, 1.2%) scale(1.15); }
  100% { transform: translate(-0.8%, 3%) scale(1.14); }
}
@keyframes glint {
  0%, 72% { transform: translateX(-46%); }
  100% { transform: translateX(46%); }
}
.stack.is-steer .scard.is-top .card-art img,
.stack.is-steer .scard.is-top .card-sheen,
.stack.is-live .scard.is-top .card-art img,
.stack.is-live .scard.is-top .card-sheen { animation: none; }
.stack.is-live .scard.is-top .card-sheen { opacity: 0; }
.scard.is-top .card-lift { will-change: transform; }

/* Live preview: the real piece in the art window */
.live-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s;
  background: #000;
}
.live-frame.is-on { opacity: 1; }
.live-tag {
  position: absolute;
  left: 2.4cqw;
  top: 2.4cqw;
  z-index: 2;
  padding: 0.8cqw 2cqw;
  border-radius: 1.2cqw;
  background: #000;
  color: var(--primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: max(9px, 3.6cqw);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.live-tag::before { content: ''; display: inline-block; width: 0.6em; height: 0.6em; margin-right: 0.4em; background: #ff3b3b; vertical-align: 0.05em; }

/* Details panel */
.info { grid-area: info; align-self: center; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.info-no { font-family: var(--font-display); font-weight: 700; color: var(--primary); letter-spacing: 0.08em; font-size: 13px; }
.info-pips { letter-spacing: 0.1em; }
.info-title { font-family: var(--font-display); font-weight: 800; font-size: clamp(26px, 4vw, 40px); line-height: 1.02; text-transform: uppercase; }
.info-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.info-desc { color: var(--text-2); font-size: 15px; }
.info-ctrl { font-size: 13px; color: var(--text-2); padding: 8px 10px; border-left: 3px solid var(--primary); background: var(--surface); }
.info-ctrl b { color: var(--primary); font-family: var(--font-display); letter-spacing: 0.06em; text-transform: uppercase; font-size: 11px; display: block; }
.info-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.live-dot { width: 8px; height: 8px; background: var(--text-3); flex: none; }
#live-btn[aria-pressed="true"] .live-dot { background: #ff3b3b; }
.info-hint { font-size: 12px; color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; font-family: var(--font-display); font-weight: 600; }
.info-hint kbd { font: inherit; padding: 1px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--text-2); }

/* Numbered tabs */
.pipnav { grid-area: pips; display: flex; align-items: center; justify-content: center; gap: 10px; padding-top: 14px; }
.pip-row { display: flex; gap: 6px; }
.pip {
  width: 38px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: var(--text-3);
  transition: transform 0.12s var(--ease-out), background-color 0.12s, color 0.12s, border-color 0.12s;
}
.pip[aria-current="true"] { background: var(--primary); border-color: var(--primary); color: var(--ink); transform: translateY(-4px); box-shadow: 3px 3px 0 #000; }
.pip-nav { width: 44px; padding: 0; }

.toast {
  position: absolute;
  left: 50%;
  top: 10px;
  z-index: 30;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 12px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--bg);
  box-shadow: 4px 4px 0 #000;
  font-size: 13px;
  color: var(--text-2);
  transform: translateX(-50%);
}

/* Phones upright: card on top, details below, tabs at the bottom. */
@media (max-width: 760px) and (orientation: portrait) {
  .browser {
    grid-template-areas: "card" "info" "pips";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    padding: 12px 16px max(10px, env(safe-area-inset-bottom));
  }
  .info { align-self: end; padding-top: 14px; gap: 8px; }
  .info-title { font-size: 26px; }
  .info-desc { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .info-ctrl, .info-hint, .info .info-tags { display: none; }
  .info-actions { flex-wrap: nowrap; }
  .info-actions .btn { flex: 1; padding: 0 10px; }
  .pipnav { padding-top: 10px; gap: 6px; }
  .pip-row { gap: 4px; }
  .pip { width: 32px; height: 40px; }
  .pip-nav { width: 40px; }
}
@media (max-width: 360px) and (orientation: portrait) {
  .pip { width: 26px; font-size: 11px; }
  .pip-nav { width: 34px; min-height: 40px; }
  .info-title { font-size: 22px; }
  .info-desc { -webkit-line-clamp: 1; }
  .info-actions .btn { font-size: 12px; padding: 0 8px; gap: 4px; }
}
@media (max-height: 600px) and (orientation: portrait) {
  .info-desc { display: none; }
  .info-no { font-size: 12px; }
}
/* Phones held sideways: card left, details and tabs right. */
@media (max-height: 500px) and (orientation: landscape) {
  .browser {
    grid-template-areas: "card info" "card pips";
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
    gap: 0 20px;
  }
  .card-area { width: calc(var(--cw) + 30px); }
  .info { gap: 6px; }
  .info-title { font-size: 22px; }
  .info-desc { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .info-ctrl, .info-hint, .info .info-tags { display: none; }
  .info-actions .btn { min-height: 38px; }
  .pipnav { justify-content: flex-start; padding-top: 6px; gap: 4px; }
  .pip-row { gap: 3px; }
  .pip { width: 28px; height: 36px; }
  .pip-nav { width: 36px; min-height: 36px; }
}

/* =====================================================================
   All pieces: a plain, accessible list
   ===================================================================== */
.all {
  padding: calc(var(--bar-h) + 28px) max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
  max-width: 1180px;
  margin: 0 auto;
}
.all-head { margin-bottom: 22px; }
.all-title { font-family: var(--font-display); font-weight: 800; font-size: clamp(28px, 5vw, 44px); line-height: 1; text-transform: uppercase; }
.all-title:focus { outline: none; }
.all-title:focus-visible { outline: 3px solid var(--primary-light); }
.all-sub { margin-top: 8px; color: var(--text-2); max-width: 60ch; }
.all-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 18px; }
.tile {
  display: flex;
  flex-direction: column;
  border: 2px solid #34353f;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 4px 4px 0 #000;
  overflow: hidden;
}
.tile[data-rarity="2"] { border-color: #5b5d6b; }
.tile[data-rarity="3"] { border-color: var(--primary-dark); }
.tile-art { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; background: #000; border-bottom: 2px solid #000; }
.tile-body { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 16px; flex: 1; }
.tile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.tile-no { color: var(--primary); }
.tile-engine { padding: 1px 7px; border-radius: 3px; background: var(--primary); color: var(--ink); }
.tile-rarity { color: var(--text-3); }
.tile-rarity span { color: var(--primary); letter-spacing: 0.1em; }
.tile-title { font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 1.1; text-transform: uppercase; }
.tile-desc { color: var(--text-2); font-size: 14px; }
.tile-tags { color: var(--text-3); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.tile-enter { align-self: flex-start; margin-top: auto; }
.all-foot { margin-top: 32px; color: var(--text-3); font-size: 14px; text-align: center; }
.all-foot a { color: var(--primary); }

/* ---------- Reduced motion: no idle loops; transitions become fades in JS ---------- */
@media (prefers-reduced-motion: reduce) {
  .pack.is-idle .pack-sheen::before, .tear-hint svg, .slot.is-next .card,
  .scard.is-top .card-art img, .scard.is-top .card-sheen { animation: none; }
  .scard.is-top .card-sheen { opacity: 0; }
  .slot .card, .btn, .icon-btn, .pip { transition: none; }
}
