/* ============================================================
   JACKIE TCG — Birthday Edition
   Teal / turquoise theme
   ============================================================ */

:root {
  --bg-deep: #02181d;
  --bg-mid: #073b42;
  --teal: #14d3c4;
  --teal-bright: #2de1d2;
  --teal-soft: #7ff0e3;
  --teal-dark: #0ea5b5;
  --ink: #032b2f;
  --text: #eafffb;
  --text-dim: #9fd6cf;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-border: rgba(45, 225, 210, 0.18);
  --gold: #ffd166;
  --radius: 20px;
  --tabbar-h: 68px;
  --font-display: 'Fredoka', 'Outfit', sans-serif;
  --font-body: 'Outfit', system-ui, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 50% -10%, var(--bg-mid), transparent 70%),
    radial-gradient(900px 600px at 100% 110%, #05343c, transparent 60%),
    var(--bg-deep);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body.no-scroll { overflow: hidden; }

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

img, video { display: block; max-width: 100%; }

/* ---------- ambient background glow blobs ---------- */
.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.ambient i {
  position: absolute;
  width: 46vw; height: 46vw;
  min-width: 320px; min-height: 320px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.16;
  animation: drift 22s ease-in-out infinite alternate;
}
.ambient i:nth-child(1) { background: #12c2b0; top: -12%; left: -10%; }
.ambient i:nth-child(2) { background: #0e7490; bottom: -18%; right: -12%; animation-delay: -7s; }
.ambient i:nth-child(3) { background: #2de1d2; top: 40%; left: 55%; width: 26vw; height: 26vw; animation-delay: -14s; opacity: 0.1; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vw, -4vh) scale(1.15); }
}

/* ============================================================
   TOP BAR
   ============================================================ */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 12px clamp(14px, 4vw, 28px);
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(3, 26, 31, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(45, 225, 210, 0.12);
}

.brand { display: flex; align-items: center; gap: 10px; user-select: none; }
.brand-card {
  display: grid; place-items: center;
  width: 34px; height: 44px;
  background: linear-gradient(150deg, var(--teal-bright), var(--teal-dark));
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700; font-size: 22px;
  border-radius: 7px;
  box-shadow: 0 4px 14px rgba(20, 211, 196, 0.4);
  transform: rotate(-6deg);
}
.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(17px, 4vw, 21px);
  letter-spacing: 1px;
}
.brand-text em {
  font-style: normal;
  color: var(--teal-bright);
  margin-left: 4px;
}

.topbar-right { display: flex; align-items: center; gap: 8px; position: relative; }

.pill {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.15s, box-shadow 0.3s;
}
.pill:active { transform: scale(0.95); }

.free-pill.ready {
  background: linear-gradient(135deg, var(--teal-bright), var(--teal-dark));
  color: var(--ink);
  border-color: transparent;
  animation: pill-pulse 1.4s ease-in-out infinite;
}
@keyframes pill-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 225, 210, 0.55); }
  50%       { box-shadow: 0 0 0 9px rgba(45, 225, 210, 0); }
}

.coin-icon {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe8a8, var(--gold) 55%, #c98a1b);
  box-shadow: inset 0 0 0 2px rgba(160, 100, 10, 0.35);
  flex: none;
}
.coin-icon.dark { box-shadow: inset 0 0 0 2px rgba(90, 55, 5, 0.5); }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  transition: transform 0.15s;
}
.icon-btn:active { transform: scale(0.92); }

.menu-pop {
  position: absolute;
  top: calc(100% + 10px); right: 0;
  min-width: 210px;
  background: rgba(6, 40, 46, 0.97);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  z-index: 40;
}
.menu-pop button {
  display: block; width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
}
.menu-pop button:hover { background: rgba(45, 225, 210, 0.12); }
.menu-credit {
  padding: 10px 12px 6px;
  font-size: 11.5px;
  color: var(--text-dim);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  margin-top: 6px;
}

/* ============================================================
   LAYOUT / SCREENS
   ============================================================ */

#app {
  position: relative; z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 36px);
  padding-bottom: calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom));
}

.screen { display: none; animation: screen-in 0.35s ease both; }
.screen.active { display: block; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   SHOP
   ============================================================ */

.hero { text-align: center; padding: clamp(10px, 3vw, 30px) 0 clamp(22px, 4vw, 40px); }

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(45, 225, 210, 0.12);
  border: 1px solid var(--panel-border);
  color: var(--teal-soft);
  font-size: 12.5px; font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(34px, 7.5vw, 58px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: 0.5px;
}

.hero-name {
  background: linear-gradient(100deg, var(--teal-bright), var(--teal-soft), var(--teal-bright));
  background-size: 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: name-shimmer 3.5s linear infinite;
}
@keyframes name-shimmer { to { background-position: 200% center; } }

.hero-sub {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: clamp(14px, 3vw, 16.5px);
  line-height: 1.55;
}

.pack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr));
  gap: clamp(14px, 2.5vw, 24px);
}

.shop-pack {
  position: relative;
  display: flex; flex-direction: column;
  gap: 16px;
  padding: clamp(18px, 3vw, 26px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.shop-pack:hover {
  transform: translateY(-6px);
  border-color: rgba(45, 225, 210, 0.45);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.35), 0 0 30px rgba(20, 211, 196, 0.08);
}
.shop-pack:hover .pack-shine { animation-duration: 1.2s; }
.shop-pack.deny { animation: deny-shake 0.4s; }

@keyframes deny-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

.shop-pack-info { text-align: center; }
.shop-pack-name {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 700;
}
.shop-pack-tag { color: var(--text-dim); font-size: 13.5px; margin-top: 3px; }
.shop-pack-guarantee {
  margin-top: 10px;
  font-size: 12.5px; font-weight: 600;
  color: var(--teal-soft);
}

.buy-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 14px;
  padding: 11px 26px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--teal-bright), var(--teal-dark));
  color: var(--ink);
  font-weight: 800; font-size: 15.5px;
  box-shadow: 0 6px 18px rgba(20, 211, 196, 0.35);
  transition: transform 0.15s, box-shadow 0.2s;
}
.shop-pack:hover .buy-btn { box-shadow: 0 8px 26px rgba(20, 211, 196, 0.5); }
.buy-btn:active { transform: scale(0.95); }

.shop-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 26px;
  line-height: 1.6;
}

/* ============================================================
   PACK ART (shared: shop + opening)
   ============================================================ */

.pack-art {
  position: relative;
  width: min(190px, 60vw);
  aspect-ratio: 3 / 4.1;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
  user-select: none;
}

.theme-classic { background: linear-gradient(160deg, #0e98a2 0%, #0a5c68 55%, #06333f 100%); }
.theme-holo    { background: linear-gradient(160deg, #16c9bc 0%, #0d7a8c 45%, #123a5e 100%); }
.theme-ultra   { background: linear-gradient(160deg, #0d5d67 0%, #05323b 60%, #021d24 100%); }

.theme-holo::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(115deg,
    rgba(255, 90, 200, 0.20), rgba(90, 200, 255, 0.20) 30%,
    rgba(120, 255, 190, 0.20) 55%, rgba(255, 230, 120, 0.20) 80%);
  mix-blend-mode: screen;
}
.theme-ultra::before {
  content: '';
  position: absolute; inset: 0;
  border: 2px solid rgba(255, 209, 102, 0.55);
  border-radius: 14px;
  box-shadow: inset 0 0 26px rgba(255, 209, 102, 0.18);
  pointer-events: none;
}
.theme-ultra .pack-logo { border-color: rgba(255, 209, 102, 0.7); }
.theme-ultra .pack-title { color: var(--gold); }

.pack-crimp {
  position: absolute; left: 0; right: 0;
  height: 13px; z-index: 3;
  background: repeating-linear-gradient(90deg,
    rgba(255, 255, 255, 0.22) 0 5px,
    rgba(0, 0, 0, 0.22) 5px 10px);
}
.crimp-top { top: 0; border-bottom: 1px solid rgba(0, 0, 0, 0.3); }
.crimp-bottom { bottom: 0; border-top: 1px solid rgba(0, 0, 0, 0.3); }

.pack-foil {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 18% 26%, rgba(255, 255, 255, 0.35) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 78% 14%, rgba(255, 255, 255, 0.3) 0 1px, transparent 2px),
    radial-gradient(circle at 62% 68%, rgba(255, 255, 255, 0.28) 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 30% 82%, rgba(255, 255, 255, 0.3) 0 1px, transparent 2px),
    radial-gradient(circle at 88% 48%, rgba(255, 255, 255, 0.25) 0 1px, transparent 2px);
  opacity: 0.7;
}

.pack-content {
  position: absolute; inset: 13px 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px;
  text-align: center;
  z-index: 2;
}

.pack-set {
  font-size: 9.5px; font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}

.pack-logo {
  display: grid; place-items: center;
  width: 68px; height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 24px rgba(127, 240, 227, 0.35), inset 0 0 16px rgba(255, 255, 255, 0.1);
}
.pack-logo span {
  font-family: var(--font-display);
  font-size: 40px; font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.pack-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  line-height: 1.1;
}

.pack-sub {
  font-size: 10px; font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.65);
}

.pack-shine {
  position: absolute; inset: -30%;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, 0.28) 50%, transparent 58%);
  animation: shine-sweep 3.4s ease-in-out infinite;
  z-index: 4;
  pointer-events: none;
}
@keyframes shine-sweep {
  0%   { transform: translateX(-60%); }
  55%, 100% { transform: translateX(60%); }
}

/* ============================================================
   TAB BAR
   ============================================================ */

.tabbar {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex; gap: 6px;
  padding: 7px;
  background: rgba(5, 33, 39, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

.tab {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 11px 26px;
  border-radius: 999px;
  font-weight: 700; font-size: 14.5px;
  color: var(--text-dim);
  transition: background 0.25s, color 0.25s, transform 0.15s;
}
.tab:active { transform: scale(0.95); }
.tab.active {
  background: linear-gradient(135deg, var(--teal-bright), var(--teal-dark));
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(20, 211, 196, 0.4);
}
.tab-icon { font-size: 17px; }

.tab-dot {
  position: absolute; top: 6px; right: 12px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: pill-pulse 1.6s infinite;
}

/* ============================================================
   OVERLAYS
   ============================================================ */

.overlay {
  position: fixed; inset: 0;
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 18, 23, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow-y: auto;
  overflow-x: hidden;
  animation: overlay-in 0.3s ease;
}
.overlay[hidden] { display: none; }

@keyframes overlay-in { from { opacity: 0; } }

.opening-stage {
  width: 100%;
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}

.screen-flash {
  position: fixed; inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(127, 240, 227, 0.5) 45%, transparent 75%);
  pointer-events: none;
  z-index: 5;
  animation: flash-fade 0.65s ease-out forwards;
}
@keyframes flash-fade { from { opacity: 1; } to { opacity: 0; } }

/* ---------- pack tearing ---------- */

.pack-wrap {
  display: flex; flex-direction: column;
  align-items: center; gap: 26px;
}

.pack-3d {
  position: relative;
  width: min(72vw, 300px);
  aspect-ratio: 3 / 4.1;
  cursor: grab;
  touch-action: none;
  animation: pack-float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 34px rgba(20, 211, 196, 0.3));
}
.pack-3d.gripped { animation: none; cursor: grabbing; transform: scale(1.03); }
.pack-3d .pack-art { width: 100%; height: 100%; aspect-ratio: auto; }

@keyframes pack-float {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-12px) rotate(1deg); }
}

.pack-piece { position: absolute; inset: 0; }
.pack-piece-top  { clip-path: inset(0 0 84% 0); z-index: 2; }
.pack-piece-body { clip-path: inset(16% 0 0 0); }

.tear-line {
  position: absolute;
  left: 0; right: 0; top: 16%;
  height: 0; z-index: 3;
  border-top: 2px dashed rgba(255, 255, 255, 0.5);
}
.tear-fill {
  position: absolute;
  left: 0; top: -2px;
  height: 3px;
  width: calc(var(--tear, 0) * 100%);
  background: #fff;
  box-shadow: 0 0 12px 2px rgba(127, 240, 227, 0.9);
  transition: width 0.05s linear;
}
.tear-spark {
  position: absolute;
  top: -13px;
  left: calc(var(--tear, 0) * 100%);
  transform: translateX(-50%) scaleX(-1);
  font-size: 20px;
  opacity: 0;
  transition: opacity 0.2s;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.8));
}
.gripped .tear-spark { opacity: 1; }

.pack-3d.ripped { animation: none; cursor: default; }
.pack-3d.ripped .tear-line { display: none; }
.pack-3d.ripped .pack-piece-top {
  animation: rip-top 0.6s cubic-bezier(0.45, -0.2, 0.8, 0.6) forwards;
}
.pack-3d.ripped .pack-piece-body {
  animation: rip-body 0.75s 0.14s cubic-bezier(0.6, 0, 0.9, 0.6) forwards;
}
@keyframes rip-top {
  20% { transform: translate(4%, -2%) rotate(2deg); }
  to  { transform: translate(-40%, -180%) rotate(-28deg); opacity: 0; }
}
@keyframes rip-body {
  30% { transform: translateY(4%); }
  to  { transform: translateY(120vh) rotate(7deg); opacity: 0; }
}

.open-hint {
  color: var(--text-dim);
  font-size: 14.5px; font-weight: 600;
  letter-spacing: 0.4px;
  animation: hint-pulse 1.8s ease-in-out infinite;
  transition: opacity 0.3s;
}
.open-hint.faded { opacity: 0.25; animation: none; }
@keyframes hint-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.open-cancel { margin-top: -6px; }

/* ============================================================
   TCG CARD
   ============================================================ */

.tcg-card {
  --card-w: 290px;
  width: var(--card-w);
  aspect-ratio: 600 / 840;
  perspective: 1400px;
  user-select: none;
  -webkit-user-drag: none;
  container-type: inline-size;
}

.card-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.3, 1.2, 0.5, 1);
}
.tcg-card.flipped .card-inner { transform: rotateY(180deg); }
.tcg-card.tilting .card-inner { transition: transform 0.07s linear; }
.tcg-card.flipped.tilting .card-inner {
  transform: rotateY(calc(180deg + var(--ry, 0deg))) rotateX(var(--rx, 0deg));
}

.card-back, .card-face {
  position: absolute; inset: 0;
  border-radius: 5.5cqw;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* --- card back --- */
.card-back {
  background: linear-gradient(155deg, #0c6b74, #053a44 60%, #032a33);
  border: 2cqw solid #0a4a54;
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.card-back-pattern {
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(45deg, rgba(45, 225, 210, 0.07) 0 2px, transparent 2px 14px),
    repeating-linear-gradient(-45deg, rgba(45, 225, 210, 0.07) 0 2px, transparent 2px 14px);
}
.card-back-logo {
  display: grid; place-items: center;
  width: 34%; aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(45, 225, 210, 0.1);
  border: 2.5px solid rgba(45, 225, 210, 0.5);
  box-shadow: 0 0 30px rgba(45, 225, 210, 0.25);
  z-index: 1;
}
.card-back-logo span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19cqw;
  color: var(--teal-soft);
}
.card-back-text {
  position: absolute;
  bottom: 7%;
  width: 100%;
  text-align: center;
  font-size: 3.8cqw;
  font-weight: 800;
  letter-spacing: 0.8cqw;
  color: rgba(127, 240, 227, 0.55);
}

/* --- card face --- */
.card-face {
  transform: rotateY(180deg);
  background: #06343d;
  border: 2.2cqw solid var(--rarity-color, #9db9c4);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.5),
    0 0 22px var(--rarity-glow, transparent);
}

.card-art { position: absolute; inset: 0; }
.card-art img, .card-art video {
  width: 100%; height: 100%;
  object-fit: cover;
}

.play-badge {
  position: absolute;
  top: 8%; right: 6%;
  display: grid; place-items: center;
  width: 14cqw;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.75);
  color: #fff;
  font-size: 5.5cqw;
  padding-left: 2px;
}

/* holo overlay for rare+ */
.card-holo { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.rarity-rare .card-holo,
.rarity-epic .card-holo,
.rarity-legendary .card-holo {
  opacity: 0.32;
  background: linear-gradient(115deg,
    rgba(255, 80, 200, 0.5) 8%, rgba(80, 190, 255, 0.5) 30%,
    rgba(90, 255, 180, 0.5) 52%, rgba(255, 230, 100, 0.5) 74%,
    rgba(255, 80, 200, 0.5) 96%);
  background-size: 300% 300%;
  mix-blend-mode: color-dodge;
  animation: holo-shift 4.5s linear infinite;
}
.rarity-legendary .card-holo { opacity: 0.42; }
@keyframes holo-shift {
  from { background-position: 0% 0%; }
  to   { background-position: 300% 0%; }
}

/* pointer glare */
.card-glare {
  position: absolute; inset: 0;
  opacity: 0;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%),
    rgba(255, 255, 255, 0.4), transparent 46%);
  transition: opacity 0.3s;
  pointer-events: none;
}
.tilting .card-glare { opacity: 1; }

/* frame / nameplate */
.card-frame {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 5cqw 5.5cqw 4.5cqw;
  background: linear-gradient(transparent, rgba(2, 22, 27, 0.88) 34%);
  pointer-events: none;
}

/* keep video controls reachable in the detail view */
.in-modal .card-art video { position: relative; z-index: 1; }
.in-modal .card-glare, .in-modal .card-holo { z-index: 2; }
.in-modal .card-frame { z-index: 3; }
.card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 5.8cqw;
  line-height: 1.18;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}
.card-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px;
  margin-top: 2cqw;
}
.card-num {
  font-size: 4cqw;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.6);
}

.rarity-chip {
  display: inline-block;
  padding: 0.22em 0.7em;
  border-radius: 999px;
  font-size: 3.8cqw;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--rc, var(--teal-bright));
  background: color-mix(in srgb, var(--rc, var(--teal-bright)) 16%, rgba(0, 0, 0, 0.5));
  border: 1px solid color-mix(in srgb, var(--rc, var(--teal-bright)) 55%, transparent);
}

/* rarity chips outside cards use fixed sizes */
.reveal-tags .rarity-chip, .col-sub .rarity-chip, .modal-tags .rarity-chip { font-size: 11px; }
.rarity-chip.big { font-size: 13px; }

/* ============================================================
   REVEAL STACK
   ============================================================ */

.stack-area {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 22px;
  width: 100%;
}

.stack {
  --card-w: min(64vw, 280px);
  position: relative;
  width: var(--card-w);
  aspect-ratio: 600 / 840;
  perspective: 1400px;
}

.stack .tcg-card {
  --card-w: 100%;
  position: absolute; inset: 0;
  width: 100%;
  cursor: pointer;
  transition: transform 0.45s cubic-bezier(0.5, 0, 0.8, 0.4), opacity 0.4s;
  transform:
    translate(calc(var(--stack-i) * 7px), calc(var(--stack-i) * 6px))
    rotate(calc(var(--stack-i) * 1.4deg));
}

.stack:not(.dealt) .tcg-card {
  transform: translateY(70vh) rotate(10deg);
  opacity: 0;
}
.stack.dealt .tcg-card {
  opacity: 1;
  transition-delay: calc(var(--stack-i) * 55ms);
}

.stack .tcg-card.fly-out {
  transform: translate(var(--fly-x, 70vw), -8vh) rotate(var(--fly-r, 20deg)) !important;
  opacity: 0 !important;
  transition-delay: 0ms;
  pointer-events: none;
}

.reveal-burst {
  position: absolute;
  left: 50%; top: 50%;
  width: 150%; aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  pointer-events: none;
  z-index: 0;
  animation: burst-out 1s ease-out forwards;
}
.reveal-burst.rarity-rare      { background: radial-gradient(circle, rgba(77, 201, 255, 0.55), transparent 62%); }
.reveal-burst.rarity-epic      { background: radial-gradient(circle, rgba(192, 125, 255, 0.6), transparent 62%); }
.reveal-burst.rarity-legendary { background: radial-gradient(circle, rgba(255, 209, 102, 0.75), rgba(255, 209, 102, 0.2) 45%, transparent 65%); }
@keyframes burst-out {
  from { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  to   { transform: translate(-50%, -50%) scale(1.7); opacity: 0; }
}

.reveal-info {
  min-height: 86px;
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
}
.reveal-name {
  font-family: var(--font-display);
  font-size: clamp(19px, 4.5vw, 25px);
  font-weight: 700;
  animation: screen-in 0.3s ease;
}
.reveal-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.reveal-hint {
  color: var(--text-dim);
  font-size: 13px; font-weight: 600;
  animation: hint-pulse 1.8s infinite;
}

.type-chip, .copies-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 11.5px; font-weight: 700;
}

.new-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), #f4a927);
  color: #4a2e00;
  font-size: 11.5px; font-weight: 800;
  letter-spacing: 0.5px;
  animation: new-pop 0.4s cubic-bezier(0.3, 1.6, 0.6, 1);
}
@keyframes new-pop { from { transform: scale(0); } to { transform: scale(1); } }

.dupe-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 11.5px; font-weight: 700;
  color: var(--gold);
}
.dupe-chip .coin-icon { width: 12px; height: 12px; }

/* ============================================================
   RESULTS
   ============================================================ */

.results {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 860px;
  padding: 10px 0 30px;
}

.results-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 5.5vw, 34px);
  font-weight: 700;
  text-align: center;
  animation: screen-in 0.4s ease;
}

.results-row {
  display: flex; flex-wrap: wrap;
  justify-content: center;
  gap: clamp(10px, 2vw, 18px);
}

.result-card {
  position: relative;
  width: clamp(100px, 17vw, 150px);
  cursor: pointer;
  opacity: 0;
  animation: card-rise 0.5s cubic-bezier(0.3, 1.3, 0.6, 1) forwards;
  animation-delay: var(--d, 0ms);
  transition: transform 0.2s;
}
.result-card:hover { transform: translateY(-6px) scale(1.04); }
.result-card .tcg-card { --card-w: 100%; width: 100%; }

@keyframes card-rise {
  from { opacity: 0; transform: translateY(40px) scale(0.7); }
  to   { opacity: 1; transform: none; }
}

.new-chip.on-card {
  position: absolute;
  top: -8px; right: -6px;
  z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.results-coins {
  display: flex; align-items: center; gap: 7px;
  color: var(--text-dim);
  font-size: 14.5px;
}
.results-coins b { color: var(--gold); }

.results-actions {
  display: flex; flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.primary-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--teal-bright), var(--teal-dark));
  color: var(--ink);
  font-weight: 800; font-size: 15.5px;
  box-shadow: 0 8px 24px rgba(20, 211, 196, 0.4);
  transition: transform 0.15s, box-shadow 0.2s;
}
.primary-btn:hover { box-shadow: 0 10px 30px rgba(20, 211, 196, 0.55); }
.primary-btn:active { transform: scale(0.95); }

.ghost-btn {
  padding: 12px 24px;
  border-radius: 999px;
  border: 1.5px solid var(--panel-border);
  color: var(--text-dim);
  font-weight: 700; font-size: 14.5px;
  transition: border-color 0.2s, color 0.2s, transform 0.15s;
}
.ghost-btn:hover { border-color: var(--teal-bright); color: var(--text); }
.ghost-btn:active { transform: scale(0.95); }

/* ============================================================
   COLLECTION
   ============================================================ */

.col-head { margin-bottom: 22px; }
.col-head h2 {
  font-family: var(--font-display);
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 700;
  margin-bottom: 14px;
}

.col-stats {
  display: flex; flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  flex: 1 1 120px;
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
}
.stat b { font-size: 20px; font-family: var(--font-display); }
.stat span { font-size: 12px; color: var(--text-dim); font-weight: 600; }

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal-dark), var(--teal-bright), var(--teal-soft));
  box-shadow: 0 0 12px rgba(45, 225, 210, 0.55);
  transition: width 0.7s cubic-bezier(0.3, 1, 0.4, 1);
}
.progress-label {
  margin-top: 7px;
  font-size: 12.5px; font-weight: 700;
  color: var(--text-dim);
}

.filter-row {
  display: flex; gap: 8px;
  margin-top: 16px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 13px; font-weight: 700;
  color: var(--text-dim);
  transition: background 0.2s, color 0.2s;
}
.chip.active {
  background: linear-gradient(135deg, var(--teal-bright), var(--teal-dark));
  color: var(--ink);
  border-color: transparent;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 44vw), 1fr));
  gap: clamp(10px, 2vw, 16px);
}

.col-cell {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 9px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.25s, border-color 0.25s;
  animation: screen-in 0.35s ease both;
}
.col-cell:not(.locked):hover {
  transform: translateY(-4px);
  border-color: var(--rarity-color);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 18px var(--rarity-glow);
}
.col-cell.locked { cursor: default; opacity: 0.75; }

.col-art {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 11px;
  overflow: hidden;
  border: 2px solid var(--rarity-color);
}
.col-art img, .col-art video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.col-art .play-badge {
  width: 34px;
  font-size: 13px;
  top: 8px; right: 8px;
}

.locked-art {
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.35);
  border: 2px dashed rgba(255, 255, 255, 0.15);
}
.locked-art span {
  font-family: var(--font-display);
  font-size: 42px; font-weight: 700;
  color: rgba(255, 255, 255, 0.18);
}

.col-info { padding: 9px 3px 3px; }
.col-name {
  font-size: 13px; font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.5em;
}
.col-sub {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
}
.copies { font-size: 12px; font-weight: 800; color: var(--text-dim); }

.unseen-dot {
  position: absolute;
  top: 14px; left: 14px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  z-index: 2;
  animation: pill-pulse 1.6s infinite;
}

.empty-note {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 15.5px;
  font-weight: 600;
}

/* ============================================================
   CARD MODAL
   ============================================================ */

#card-modal { z-index: 70; }

.modal-close {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: 18px;
  z-index: 75;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 17px;
  color: var(--text);
}

.modal-body {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: clamp(20px, 4vw, 44px);
  padding: 70px 20px 40px;
  max-width: 940px;
  width: 100%;
  margin: auto;
}

.modal-body .tcg-card.in-modal {
  --card-w: min(76vw, 340px);
  animation: modal-card-in 0.45s cubic-bezier(0.3, 1.3, 0.6, 1);
}
@keyframes modal-card-in {
  from { opacity: 0; transform: translateY(30px) scale(0.85); }
  to   { opacity: 1; transform: none; }
}

.modal-details {
  max-width: 340px;
  display: flex; flex-direction: column;
  gap: 13px;
  animation: screen-in 0.45s 0.1s ease both;
}
.modal-name {
  font-family: var(--font-display);
  font-size: clamp(23px, 5vw, 30px);
  font-weight: 700;
  line-height: 1.15;
}
.modal-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-flavor {
  color: var(--text-dim);
  font-size: 15px;
  font-style: italic;
  line-height: 1.6;
}
.modal-num { font-size: 12.5px; font-weight: 700; color: var(--text-dim); }
.modal-note {
  font-size: 12.5px;
  color: var(--gold);
  background: rgba(255, 209, 102, 0.08);
  border: 1px solid rgba(255, 209, 102, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
}

.video-missing {
  display: grid; place-items: center;
  height: 100%;
  text-align: center;
  font-size: 15px; font-weight: 700;
  color: var(--text-dim);
  line-height: 2.2;
}

/* ============================================================
   CELEBRATION
   ============================================================ */

.celebrate {
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  padding: 30px;
}
.celebrate-emoji { font-size: 52px; animation: pack-float 2.5s infinite; }
.celebrate h2 {
  font-family: var(--font-display);
  font-size: clamp(30px, 7vw, 46px);
  color: var(--gold);
}
.celebrate p { color: var(--text-dim); font-size: 16px; line-height: 1.6; }
.celebrate-big {
  font-family: var(--font-display);
  font-size: clamp(22px, 5.5vw, 32px) !important;
  font-weight: 700;
  background: linear-gradient(100deg, var(--teal-bright), var(--gold), var(--teal-bright));
  background-size: 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent !important;
  animation: name-shimmer 3s linear infinite;
}

/* ============================================================
   CONFETTI / TOASTS / MISC
   ============================================================ */

#confetti-canvas {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 90;
}

#toast-holder {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  z-index: 95;
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}

.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  background: rgba(6, 44, 51, 0.96);
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 14px; font-weight: 600;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.35s, transform 0.35s;
  max-width: 92vw;
}
.toast.show { opacity: 1; transform: none; }

body.shake { animation: body-shake 0.5s; }
@keyframes body-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-7px, 3px); }
  40% { transform: translate(6px, -3px); }
  60% { transform: translate(-5px, 2px); }
  80% { transform: translate(4px, -2px); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 560px) {
  .brand-text { display: none; }
  .tab { padding: 11px 20px; }
  .stack { --card-w: min(74vw, 280px); }
  .result-card { width: clamp(94px, 27vw, 130px); }
  .modal-body { padding-top: 80px; }
}

@media (min-width: 561px) and (max-width: 900px) {
  .result-card { width: clamp(110px, 18vw, 150px); }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .ambient i, .pack-shine, .pack-3d, .hero-name,
  .card-holo, .celebrate-emoji { animation: none !important; }
  * { transition-duration: 0.01s !important; }
  .stack:not(.dealt) .tcg-card { transform: none; opacity: 1; }
}
