/* ==========================================================================
   POKÉRIP — Pack opening simulator
   ========================================================================== */

:root {
  --bg-0: #07091a;
  --bg-1: #0d1130;
  --bg-2: #161a45;
  --ink: #f4f6ff;
  --ink-dim: #aab0d8;
  --ink-faint: #7077a8;
  --accent: #ffcb05;        /* pokémon yellow */
  --accent-2: #3b4cca;      /* pokémon blue */
  --accent-3: #ff1c1c;      /* pokémon red */
  --accent-4: #2bd4a8;      /* mint */
  --accent-5: #b46cff;      /* arcane */
  --rare-common: #c8cee0;
  --rare-uncommon: #6cd66c;
  --rare-rare: #58a6ff;
  --rare-ultra: #b46cff;
  --rare-secret: #ffd34d;
  --rare-chase: #ff5cf0;

  --panel: rgba(20, 24, 60, 0.55);
  --panel-line: rgba(120, 130, 220, 0.18);
  --shadow-deep: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --shadow-soft: 0 8px 24px -8px rgba(0, 0, 0, 0.45);
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --t-fast: 180ms;
  --t-base: 320ms;
  --t-slow: 600ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.6, 0, 0.4, 1);
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: radial-gradient(ellipse at top, #1a1f55 0%, var(--bg-0) 55%, #02030c 100%);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* ---------------- Static background ---------------- */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(rgba(120, 140, 255, 0.04) 1px, transparent 1px) 0 0 / 60px 60px,
    linear-gradient(90deg, rgba(120, 140, 255, 0.04) 1px, transparent 1px) 0 0 / 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 30%, transparent 80%);
}

/* ---------------- Topbar ---------------- */
.topbar {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--panel-line);
  backdrop-filter: blur(8px);
  background: rgba(7, 9, 26, 0.5);
}
/* Inner wrapper aligns topbar content with the page container (max 1200px). */
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 800; letter-spacing: 0.04em;
}
.logo-mark {
  width: 30px; height: 30px;
  background-image: url("../images/icon.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 0 10px rgba(255, 28, 28, 0.5));
}
.logo-text { font-size: 18px; }
.logo-accent { color: var(--accent); }
.topbar-spacer { flex: 1; }

/* Top nav links */
.topnav {
  display: flex; align-items: center; gap: 4px;
}
.topnav a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.topnav a:hover { background: rgba(255,255,255,0.06); color: var(--ink); }
.topnav a.active { color: var(--ink); background: rgba(255,255,255,0.08); }

/* Random Pack button — small text+icon button */
.random-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px;
  background: rgba(255, 203, 5, 0.12);
  border: 1px solid rgba(255, 203, 5, 0.35);
  color: var(--accent);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.random-btn:hover {
  background: rgba(255, 203, 5, 0.2);
  border-color: rgba(255, 203, 5, 0.55);
  transform: translateY(-1px);
}
.random-btn svg { transition: transform var(--t-base); }
.random-btn:hover svg { transform: rotate(90deg); }

@media (max-width: 540px) {
  .random-btn span { display: none; }   /* icon-only on tight screens */
  .random-btn { padding: 8px; }
  .topnav a { padding: 6px 10px; font-size: 13px; }
  .topbar-inner { padding: 14px 14px; gap: 10px; }
  .topnav { gap: 0; }
  .brand .logo-text { display: none; }   /* keep mark only — saves ~95px */
}
/* ---------------- Screens ---------------- */
#app {
  position: relative; z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 28px 80px;
}
.screen { display: none; animation: screenIn 320ms var(--ease-out); }
.screen.active { display: block; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------- Hero ---------------- */
.hero {
  text-align: center;
  padding: 28px 0 36px;
}
.hero-title {
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffffff 0%, #c1c8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub {
  margin-top: 8px;
  color: var(--ink-dim);
  font-size: 16px;
}

/* ---------------- Filters ---------------- */
.filters {
  display: flex; flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 24px;
  align-items: center;
}
.search-wrap { position: relative; flex: 1 1 320px; min-width: 240px; max-width: 480px; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint);
}
#search-input {
  width: 100%;
  padding: 12px 14px 12px 38px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--r-md);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast);
}
#search-input::placeholder { color: var(--ink-faint); }
#search-input:focus { border-color: var(--accent); background: rgba(20, 24, 60, 0.75); }

#series-filter {
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--r-md);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}
#series-filter option { background: var(--bg-1); color: var(--ink); }

.chip-btn {
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}
.chip-btn:hover { background: rgba(255,255,255,0.08); color: var(--ink); }
.chip-btn.active {
  background: linear-gradient(135deg, var(--accent), #ffaa00);
  color: #1a1a1a;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(255,203,5,0.35);
}

/* ---------------- Grid loader ---------------- */
.grid-loader {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 0;
  color: var(--ink-dim);
}
.grid-loader.active { display: flex; }
.pokeball-loader {
  width: 56px; height: 56px;
  background-image: url("../images/icon.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation: spin 1s linear infinite;
  filter: drop-shadow(0 0 14px rgba(255, 28, 28, 0.45));
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Pack grid ---------------- */
.pack-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  /* Reserve enough vertical space that JS populating the grid doesn't push
     the SEO content below into a layout shift. Two rows of pack-cards
     (280px tall) + gap is roughly the first-paint area users see. After JS
     fills the full ~200 sets the grid grows past this floor. */
  min-height: 300px;
}
@media (max-width: 720px) {
  .pack-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

.pack-card {
  position: relative;
  height: 280px;
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base);
  isolation: isolate;
}
.pack-card::before {
  /* spotlight reveal */
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.18), transparent 40%);
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: none;
  z-index: 2;
}
.pack-card:hover { transform: translateY(-6px) scale(1.02); box-shadow: var(--shadow-deep); }
.pack-card:hover::before { opacity: 1; }

.pack-card .bg {
  position: absolute; inset: 0;
  background: var(--card-bg, linear-gradient(135deg, #2b1a4d 0%, #08081e 100%));
  filter: saturate(1.1);
  z-index: 0;
}
.pack-card .bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,0.85) 100%);
}
.pack-card .logo-img {
  position: absolute;
  left: 50%; top: 38%;
  transform: translate(-50%, -50%);
  max-width: 78%;
  max-height: 50%;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
  z-index: 1;
}
.pack-card .info {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 16px;
  z-index: 3;
}
.pack-card .info h3,
.pack-card .info .set-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.pack-card .info .meta {
  display: flex; gap: 8px; font-size: 11px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.pack-card .symbol-img {
  position: absolute; right: 10px; top: 10px;
  width: 26px; height: 26px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 5px;
  object-fit: contain;
  z-index: 2;
}

/* Series-themed gradients (assigned by JS) */
.theme-sv  { --card-bg: linear-gradient(135deg, #6c2c8e 0%, #2b1245 100%); }
.theme-swsh { --card-bg: linear-gradient(135deg, #2c5a8e 0%, #122b45 100%); }
.theme-sm  { --card-bg: linear-gradient(135deg, #ff9248 0%, #5a1a45 100%); }
.theme-xy  { --card-bg: linear-gradient(135deg, #1f8e7e 0%, #102b3d 100%); }
.theme-bw  { --card-bg: linear-gradient(135deg, #1a1a1a 0%, #424252 100%); }
.theme-hgss { --card-bg: linear-gradient(135deg, #ffba2a 0%, #5a3010 100%); }
.theme-pl  { --card-bg: linear-gradient(135deg, #6a7080 0%, #1a1f30 100%); }
.theme-dp  { --card-bg: linear-gradient(135deg, #4263c8 0%, #ff6cb8 100%); }
.theme-ex  { --card-bg: linear-gradient(135deg, #c83244 0%, #2a0a14 100%); }
.theme-base { --card-bg: linear-gradient(135deg, #e2c14a 0%, #4d3010 100%); }
.theme-me  { --card-bg: linear-gradient(135deg, #ff3b85 0%, #2b0a45 100%); }
.theme-A   { --card-bg: linear-gradient(135deg, #1aaad6 0%, #122b45 100%); }
.theme-B   { --card-bg: linear-gradient(135deg, #c83244 0%, #2b0a14 100%); }
.theme-tcgp { --card-bg: linear-gradient(135deg, #4a2a8e 0%, #08081e 100%); }
.theme-ecard { --card-bg: linear-gradient(135deg, #4a8eaf 0%, #1a2d3d 100%); }
.theme-col  { --card-bg: linear-gradient(135deg, #ffba2a 0%, #5a3010 100%); }
.theme-neo  { --card-bg: linear-gradient(135deg, #4a7d4a 0%, #1a2d1a 100%); }
.theme-gym  { --card-bg: linear-gradient(135deg, #8e482c 0%, #2a1a10 100%); }
.theme-pop  { --card-bg: linear-gradient(135deg, #2bd4a8 0%, #103030 100%); }
.theme-default { --card-bg: linear-gradient(135deg, #2b3a8e 0%, #08081e 100%); }

/* ============= Pack Open Screen ============= */
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-line);
  color: var(--ink);
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
}
.back-btn:hover { background: rgba(255,255,255,0.1); transform: translateX(-2px); }

.open-stage {
  text-align: center;
}

/* Mode toggle pills (Quick / Auto-flip) */
.mode-toggles {
  display: flex; justify-content: center; gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.mode-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  color: var(--ink-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all var(--t-fast);
}
.mode-pill:hover { background: rgba(255,255,255,0.08); color: var(--ink); }
.mode-pill.active {
  background: rgba(255, 203, 5, 0.15);
  border-color: rgba(255, 203, 5, 0.45);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(255, 203, 5, 0.18);
}
.set-title {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.set-meta {
  color: var(--ink-dim);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

/* ---------------- Pack 3D ---------------- */
.pack-wrap {
  position: relative;
  margin: 36px auto 0;
  width: 280px; height: 440px;
  perspective: 1200px;
}
.pack-shadow {
  position: absolute;
  left: 50%; bottom: -24px;
  transform: translateX(-50%);
  width: 240px; height: 30px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.6), transparent 70%);
  filter: blur(6px);
  animation: packBob 3s ease-in-out infinite;
}
@keyframes packBob {
  0%, 100% { transform: translateX(-50%) scaleX(1); opacity: 0.7; }
  50% { transform: translateX(-50%) scaleX(0.85); opacity: 0.5; }
}
.pack {
  position: absolute; inset: 0;
  border-radius: 18px;
  cursor: grab;
  transform-style: preserve-3d;
  transform: rotateY(-12deg) rotateX(4deg);
  transition: transform var(--t-base) var(--ease-out);
  animation: packFloat 4s ease-in-out infinite;
  user-select: none;
  outline: none;
}
@keyframes packFloat {
  0%, 100% { transform: rotateY(-12deg) rotateX(4deg) translateY(0); }
  50% { transform: rotateY(-8deg) rotateX(2deg) translateY(-10px); }
}
.pack:hover { transform: rotateY(-6deg) rotateX(2deg) scale(1.03); animation-play-state: paused; }
.pack.shaking { animation: packShake 80ms ease-in-out infinite; }
@keyframes packShake {
  0%, 100% { transform: rotateY(-12deg) rotateX(4deg) translateX(0); }
  25% { transform: rotateY(-12deg) rotateX(4deg) translateX(-3px) translateY(-1px); }
  75% { transform: rotateY(-12deg) rotateX(4deg) translateX(3px) translateY(1px); }
}

.pack-art {
  position: absolute; inset: 0;
  border-radius: 18px;
  overflow: hidden;
  background:
    linear-gradient(180deg, #1a1f55 0%, #0c0f33 100%);
  box-shadow:
    0 30px 60px -20px rgba(0, 0, 0, 0.7),
    inset 0 0 0 2px rgba(255, 255, 255, 0.08),
    inset 0 -40px 80px rgba(0, 0, 0, 0.4);
}
.pack-art::before {
  /* set-themed background */
  content: "";
  position: absolute; inset: 0;
  background: var(--pack-bg, linear-gradient(135deg, #4a2a8e 0%, #08081e 100%));
  z-index: 0;
}
.pack-art::after {
  /* shine streaks */
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(115deg,
    transparent 30%,
    rgba(255,255,255,0.18) 45%,
    rgba(255,255,255,0.05) 50%,
    rgba(255,255,255,0.18) 55%,
    transparent 70%);
  background-size: 200% 100%;
  animation: shineSlide 5s linear infinite;
  pointer-events: none;
  mix-blend-mode: overlay;
}
@keyframes shineSlide {
  from { background-position: 200% 0; }
  to   { background-position: -50% 0; }
}

.pack-foil {
  /* holographic gradient layer */
  position: absolute; inset: 0;
  border-radius: 18px;
  background: conic-gradient(from var(--foil-angle, 0deg),
    #ff80ff, #80c0ff, #80ffc0, #ffe080, #ff80c0, #ff80ff);
  opacity: 0.18;
  mix-blend-mode: color-dodge;
  pointer-events: none;
  z-index: 1;
  animation: foilSpin 8s linear infinite;
}
@keyframes foilSpin {
  from { --foil-angle: 0deg; transform: rotate(0deg); }
  to   { --foil-angle: 360deg; transform: rotate(360deg); }
}
@property --foil-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

.pack-top {
  position: absolute; top: 0; left: 0; right: 0;
  height: 32px;
  background: rgba(0,0,0,0.5);
  z-index: 4;
  border-bottom: 1px dashed rgba(255,255,255,0.15);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.pack-serration {
  position: absolute; left: 0; right: 0; bottom: -5px; height: 10px;
  background:
    linear-gradient(135deg, transparent 50%, currentColor 50%) 0 0 / 10px 10px,
    linear-gradient(45deg, transparent 50%, currentColor 50%) 0 0 / 10px 10px;
  color: rgba(0,0,0,0.25);
  opacity: 0.7;
}

.pack-body {
  position: absolute; inset: 32px 16px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 2;
}
.pack-logo {
  max-width: 90%;
  max-height: 60%;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
  z-index: 2;
}
.pack-stripe {
  position: absolute; left: -10px; right: -10px;
  height: 32px;
  bottom: 76px;
  background: linear-gradient(90deg, var(--accent), #ffaa00, var(--accent));
  transform: skewY(-2deg);
  box-shadow: 0 0 18px rgba(255,203,5,0.5);
  z-index: 1;
}
.pack-symbol-row {
  position: absolute; bottom: 18px; left: 18px; right: 18px;
  display: flex; align-items: center; gap: 10px;
  z-index: 3;
}
.pack-symbol {
  width: 28px; height: 28px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 5px;
  object-fit: contain;
}
.pack-edition {
  font-size: 10px;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
}

.pack-shimmer {
  position: absolute; inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%),
    rgba(255,255,255,0.4), transparent 30%);
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
  z-index: 3;
  border-radius: 18px;
  mix-blend-mode: overlay;
}
.pack:hover .pack-shimmer { opacity: 1; }

.pack-rip-line {
  position: absolute; left: 0; right: 0; top: 32px;
  height: 0; pointer-events: none;
  border-top: 2px dashed transparent;
  z-index: 4;
  transition: border-color var(--t-fast);
}
.pack.ripping .pack-rip-line { border-top-color: rgba(255, 220, 100, 0.9); }

/* The actual rip: top tears off and flies away */
.pack > .pack-top {
  transition: transform 800ms var(--ease-out), opacity 600ms 200ms;
  transform-origin: top left;
}
.pack.opened > .pack-top {
  transform: translateY(-220px) translateX(40px) rotate(-30deg);
  opacity: 0;
}
.pack.opened {
  animation: packBlast 800ms var(--ease-out) forwards;
}
@keyframes packBlast {
  0%   { transform: rotateY(-12deg) rotateX(4deg) scale(1); }
  30%  { transform: rotateY(-12deg) rotateX(4deg) scale(1.05); }
  100% { transform: rotateY(-12deg) rotateX(4deg) scale(0.6) translateY(280px); opacity: 0; }
}

.pack-burst {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
}
.pack-burst.firing {
  animation: burstFlash 800ms var(--ease-out);
}
@keyframes burstFlash {
  0%   { opacity: 0; transform: scale(0.5); }
  20%  { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(2.5); }
}
.pack-burst::before, .pack-burst::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.95), rgba(255,210,80,0.7) 30%, transparent 60%);
  filter: blur(2px);
}
.pack-burst::after {
  background: radial-gradient(circle, transparent 40%, rgba(255,255,255,0.6) 50%, transparent 70%);
  animation: ringPulse 800ms var(--ease-out);
}
@keyframes ringPulse {
  from { transform: scale(0.3); opacity: 1; }
  to { transform: scale(2.5); opacity: 0; }
}

.pack-instruction {
  position: absolute; bottom: -56px; left: 0; right: 0;
  text-align: center;
  color: var(--ink-dim);
  font-size: 13px;
}
.pack-instruction.hidden { opacity: 0; }

/* Loading state while resolvePack is in flight: replace the set-logo area
   on the pack with a big spinner + label, so the user sees clearly that
   the pack isn't ready yet. The pack frame stays vibrant. */
.pack-loading-overlay {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 5;
  pointer-events: none;
}
.pack-wrap.loading .pack {
  cursor: wait;
}
.pack-wrap.loading .pack-loading-overlay { display: flex; }
.pack-wrap.loading .pack-logo { opacity: 0; }
.pack-wrap.loading .pack-instruction { opacity: 0; }
.pack-big-spinner {
  width: 60px; height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  filter: drop-shadow(0 0 12px rgba(255, 203, 5, 0.4));
}
.pack-loading-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.kbd {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--panel-line);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink);
}
/* Show "CLICK" on devices that hover (mouse), "TAP" on touch-only devices. */
.kbd-tap { display: none; }
@media (hover: none) and (pointer: coarse) {
  .kbd-click { display: none; }
  .kbd-tap { display: inline; }
}

.rip-bar {
  position: absolute; left: 50%; bottom: -30px;
  transform: translateX(-50%);
  width: 200px; height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.rip-bar.active { opacity: 1; }
.rip-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  box-shadow: 0 0 12px rgba(255,203,5,0.7);
  transition: width 80ms linear;
}

/* ---------------- Reveal stack ---------------- */
.reveal-wrap {
  position: relative;
  /* Counter pill sits at top:-36px, so margin must be ≥36px or it overlaps
     the mode-toggles row above. 60px leaves ~24px of breathing room. */
  margin: 60px auto 0;
  width: min(360px, 90vw);
  /* Just enough taller than the 392px card to leave a hint of breathing
     room without leaving a big empty area like the original 540px did. */
  height: 430px;
  perspective: 1500px;
}
.reveal-counter {
  position: absolute; top: -36px; left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  font-weight: 700;
  padding: 4px 10px;
  background: rgba(20, 24, 60, 0.6);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.reveal-stack {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  transform-style: preserve-3d;
}
.reveal-hint {
  position: absolute; bottom: -36px; left: 0; right: 0;
  text-align: center; color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.06em;
  transition: opacity 200ms;
}
/* Once the user flips any card, the "click to reveal" hint is no longer
   useful — and its position overlaps the card-label that appears under
   flipped cards. Fade it out. The .any-flipped fallback is set by JS for
   browsers without :has() support. */
.reveal-wrap:has(.card.flipped) .reveal-hint,
.reveal-wrap.any-flipped .reveal-hint { opacity: 0; pointer-events: none; }

/* ---------------- Card ---------------- */
.card-slot {
  position: absolute;
  width: 280px; height: 392px;
  display: flex; align-items: center; justify-content: center;
}
.card {
  position: absolute;
  width: 280px; height: 392px;
  border-radius: 16px;
  transform-style: preserve-3d;
  transition: transform var(--t-slow) var(--ease-out), opacity var(--t-base);
  cursor: pointer;
  --rx: 0deg;
  --ry: 0deg;
  --tx: 0px;
  --ty: 0px;
  --rot: 0deg;
  --scale: 1;
  transform:
    translate(var(--tx), var(--ty))
    rotate(var(--rot))
    perspective(900px)
    rotateX(var(--rx))
    rotateY(var(--ry))
    scale(var(--scale));
}
.card.flipped { --ry: 180deg; }
.card.dismissed {
  /* Simple, bulletproof fade-out. Trying to slide the card off-screen
     requires interpolating between the base var-driven 6-function transform
     and an explicit literal, which browsers handle inconsistently and
     turned out to break the flip on mobile. A clean opacity fade reads as
     "card put away" and works the same on every device. */
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease-out;
}
.card-face {
  position: absolute; inset: 0;
  border-radius: 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  /* Lift the card off the dark page bg + cards stacked behind it:
     - drop shadow for depth
     - 1px white outline for crisp edge definition
     - wider soft white halo so the top card visibly separates from the stack */
  box-shadow:
    0 20px 40px -10px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.22),
    0 0 28px rgba(200, 215, 255, 0.14);
  /* Browsers don't always respect backface-visibility when faces have
     overflow:hidden + child stacking contexts, so we also swap opacity
     once the card crosses 90°. With ease-out the card reaches edge-on
     near ~100ms of the 600ms rotation. */
  transition: opacity 0s linear 100ms;
}
.card-front { opacity: 0; }
.card-back  { opacity: 1; }
.card.flipped .card-front { opacity: 1; }
.card.flipped .card-back  { opacity: 0; }

/* Card back — pokéball centered over the back.png swirl image,
   with a thick dark-navy inner border. */
.card-back {
  /* Inherits position:absolute; inset:0 from .card-face — do NOT set
     position: relative here, or the back collapses to its content height. */
  background: url('../images/back.webp') center / cover no-repeat;
  /* Inset: dark-navy inner border framing the swirl (mirrors real card edge).
     Outset: same lift shadows as .card-face — re-declared because this
     box-shadow rule replaces (not extends) the parent's. */
  box-shadow:
    inset 0 0 0 14px #0a1640,
    0 20px 40px -10px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.22),
    0 0 28px rgba(200, 215, 255, 0.14);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
/* (Removed gold inner frame — real cards don't have one.) */
.card-back-pokeball {
  width: 158px; height: 158px;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  position: relative;
  z-index: 2;
}

/* Card front */
.card-front {
  transform: rotateY(180deg);
  background: #000;
}
.card-front img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* Holo overlay (only on rare+ cards) */
.card-front::before {
  content: "";
  position: absolute; inset: 0;
  background:
    /* glare highlight follows mouse */
    radial-gradient(farthest-corner circle at var(--mx, 50%) var(--my, 50%),
      rgba(255,255,255,0.85) 8%, rgba(255,255,255,0.2) 18%, transparent 30%);
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
  z-index: 2;
}
.card-front::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.55) 50%, transparent 70%),
    repeating-linear-gradient(115deg, #ff80ff 0%, #80c0ff 14%, #80ffc0 29%, #ffe080 43%, #ff80c0 57%, #ff80ff 71%, #80c0ff 86%);
  background-size: 200% 200%, 250% 250%;
  background-position: var(--bx, 50%) var(--by, 50%), 0 0;
  mix-blend-mode: color-dodge;
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
  z-index: 1;
}
.card.holo:hover .card-front::before,
.card.holo.flipped .card-front::before { opacity: 1; }
.card.holo.flipped .card-front::after { opacity: var(--holo-strength, 0.55); }

.card.holo .card-front {
  box-shadow:
    0 20px 40px -10px rgba(0,0,0,0.7),
    0 0 0 1px rgba(255,255,255,0.1),
    0 0 28px var(--rare-glow, rgba(180, 108, 255, 0.4));
}

/* Rarity-tinted glow */
.card.r-rare       { --rare-glow: rgba(88, 166, 255, 0.45); --holo-strength: 0.35; }
.card.r-ultra      { --rare-glow: rgba(180, 108, 255, 0.6);  --holo-strength: 0.55; }
.card.r-secret     { --rare-glow: rgba(255, 211, 77, 0.7);   --holo-strength: 0.7; }
.card.r-chase      { --rare-glow: rgba(255, 92, 240, 0.85);  --holo-strength: 0.85; }

/* Pulse on rare reveal */
.card.r-ultra.flipped .card-front,
.card.r-secret.flipped .card-front,
.card.r-chase.flipped .card-front {
  animation: rarePulse 1.6s ease-out;
}
@keyframes rarePulse {
  0%   { box-shadow: 0 0 0 0 var(--rare-glow), 0 20px 40px -10px rgba(0,0,0,0.7); }
  40%  { box-shadow: 0 0 0 32px transparent, 0 20px 40px -10px rgba(0,0,0,0.7), 0 0 60px var(--rare-glow); }
  100% { box-shadow: 0 0 0 0 transparent, 0 20px 40px -10px rgba(0,0,0,0.7), 0 0 28px var(--rare-glow); }
}

/* Sparkle particles (added by JS for ultra+) */
.spark {
  position: absolute;
  width: 6px; height: 6px;
  background: radial-gradient(circle, #fff 0%, #ffcb05 50%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  animation: sparkFly 1.2s ease-out forwards;
}
@keyframes sparkFly {
  0%   { transform: translate(0, 0) scale(0); opacity: 1; }
  20%  { transform: translate(0, 0) scale(1.4); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* Beam burst behind ultra+ — sits in .card-slot, extends past the card.
   Animation only fires once the slot is flipped. */
.beam-burst {
  position: absolute; left: 50%; top: 50%;
  width: 0; height: 0;
  pointer-events: none;
  z-index: 0;
}
.beam-burst.r-rare,
.beam-burst.r-uncommon,
.beam-burst.r-common { display: none; }
.beam-burst::before, .beam-burst::after {
  content: "";
  position: absolute; left: 0; top: 0;
  width: 12px; height: 600px;
  background: linear-gradient(180deg, transparent, var(--rare-glow, #fff), transparent);
  transform-origin: 50% 50%;
  transform: translate(-50%, -50%) scale(0);
  filter: blur(3px);
  opacity: 0;
}
.beam-burst::after { width: 600px; height: 12px; }
.card-slot.flipped .beam-burst::before { animation: beamSpin1 1.6s ease-out forwards; }
.card-slot.flipped .beam-burst::after  { animation: beamSpin2 1.6s ease-out forwards; }
@keyframes beamSpin1 {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scale(0); }
  30%  { opacity: 1; transform: translate(-50%, -50%) rotate(40deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(220deg) scale(1.4); }
}
@keyframes beamSpin2 {
  0%   { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scale(0); }
  30%  { opacity: 1; transform: translate(-50%, -50%) rotate(-30deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-180deg) scale(1.4); }
}

/* Reveal label — two-line stack with rarity tier + card name.
   Sibling of .card inside .card-slot so it isn't rotated by the card's flip. */
.card-label {
  position: absolute;
  bottom: -76px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: none;
  z-index: 5;
  text-align: center;
  white-space: nowrap;
}
.card-label-tier {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--label-color, var(--ink-faint));
  text-shadow: 0 0 14px var(--label-glow, transparent);
}
/* Decorative side rules — subtle "official label" feel */
.card-label-tier::before,
.card-label-tier::after {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
  opacity: 0.45;
}
.card-label-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}
/* Rarity-tinted tier color + name glow. Defined on .card-label itself
   so the variables actually cascade to the children (the previous
   --rare-glow inheritance from .card didn't, since label sits beside
   .card not inside it). */
.card-label.r-common,
.card-label.r-uncommon { --label-color: #c8cee0; --label-glow: rgba(120, 130, 200, 0.4); }
.card-label.r-rare     { --label-color: #6cb6ff; --label-glow: rgba(88, 166, 255, 0.55); }
.card-label.r-ultra    { --label-color: #c08aff; --label-glow: rgba(180, 108, 255, 0.65); }
.card-label.r-secret   { --label-color: #ffd34d; --label-glow: rgba(255, 211, 77, 0.7); }
.card-label.r-chase    { --label-color: #ff7cf0; --label-glow: rgba(255, 92, 240, 0.85); }
.card-slot.flipped .card-label { opacity: 1; }
/* Once a slot has been dismissed (its card slid off), suppress its label so
   labels from previously-pulled cards don't pile up under the active card.
   The .dismissed rule sits after .flipped on purpose: a slot that's both
   flipped AND dismissed should hide its label, and same-specificity rules
   are resolved by source order. */
.card-slot.dismissed .card-label { opacity: 0; transition: opacity 120ms; }

/* ---------------- Summary ---------------- */
.summary-header {
  text-align: center;
  padding: 16px 0 24px;
}
.summary-header h2 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
}
.summary-header p { color: var(--ink-dim); margin-top: 4px; }
/* Shared-pull view banner — replaces the saved-strip in shared mode */
.summary-shared-banner {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  justify-content: center;
  margin: 8px auto 16px;
  padding: 14px 22px;
  background: linear-gradient(135deg, rgba(108, 182, 255, 0.12), rgba(180, 108, 255, 0.08));
  border: 1px solid rgba(108, 182, 255, 0.32);
  border-radius: var(--r-md);
  width: fit-content;
  max-width: calc(100% - 32px);
  font-size: 14px;
  color: var(--ink);
}
.summary-shared-banner .shared-eye { font-size: 18px; }
/* Hide the saved-strip and "rip again / choose different set" actions
   when the summary is showing a shared pull. */
#screen-summary.shared-view .summary-saved-strip,
#screen-summary.shared-view #open-another-btn,
#screen-summary.shared-view #back-to-sets-btn,
#screen-summary.shared-view #share-btn { display: none; }

/* Saved-to-binder confirmation strip */
.summary-saved-strip {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  justify-content: center;
  margin: 14px auto 4px;
  padding: 12px 16px;
  background: rgba(108, 214, 108, 0.08);
  border: 1px solid rgba(108, 214, 108, 0.25);
  border-radius: 999px;
  width: fit-content;
  font-size: 13px;
  color: var(--ink-dim);
}
.summary-saved-strip strong { color: var(--ink); font-weight: 700; }
.summary-saved-strip .saved-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--rare-uncommon); color: #062a08;
}
.summary-saved-strip .saved-link {
  color: var(--rare-uncommon);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color var(--t-fast);
}
.summary-saved-strip .saved-link:hover { color: #fff; }

/* Streak / pity counter strip */
.summary-streak-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  justify-content: center;
  margin: 10px auto 4px;
  padding: 6px 14px;
  background: rgba(255, 140, 0, 0.08);
  border: 1px solid rgba(255, 140, 0, 0.28);
  border-radius: 999px;
  width: fit-content;
  font-size: 12.5px;
  color: var(--ink-dim);
  letter-spacing: 0.01em;
}
.summary-streak-strip strong { color: #ffae42; font-weight: 800; }
.summary-streak-strip .streak-flame { color: #ff8c00; }
/* Hide both strips when in shared-pull view */
#screen-summary.shared-view .summary-streak-strip { display: none; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding: 16px 0;
}
@media (max-width: 720px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
.summary-card {
  position: relative;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 240 / 336;
  background: var(--panel);
  cursor: pointer;
  isolation: isolate;
  transition: transform 200ms ease-out, border-color 200ms ease-out, box-shadow 200ms ease-out;
  /* Entrance: fade-in only, staggered by position. Transform is owned by
     :hover so the two never fight. fill-mode: backwards keeps cards hidden
     until their delay elapses; after the animation ends, hover transitions
     work cleanly because the keyframes don't touch transform. */
  animation: summaryFadeIn 360ms ease-out backwards;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.summary-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 203, 5, 0.4);
  box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.6);
  z-index: 5;
}
@keyframes summaryFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.summary-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.summary-card .badge {
  position: absolute; top: 8px; right: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  color: #fff;
  z-index: 2;
}
.summary-card.r-ultra .badge { background: linear-gradient(135deg, var(--accent-5), #5d3aa2); }
.summary-card.r-secret .badge { background: linear-gradient(135deg, #ffd34d, #ff8c00); color: #1a1a1a; }
.summary-card.r-chase .badge {
  background: linear-gradient(135deg, var(--rare-chase), #6a1aff);
  animation: chasePulse 1.5s ease-in-out infinite;
}
@keyframes chasePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,92,240, 0.6); }
  50% { box-shadow: 0 0 0 8px transparent; }
}
.summary-card.r-rare .badge { background: linear-gradient(135deg, var(--rare-rare), #2a4d8e); }
.summary-card.r-uncommon .badge { background: linear-gradient(135deg, var(--rare-uncommon), #2a8e3a); }

.summary-actions {
  display: flex; gap: 12px; justify-content: center;
  margin-top: 32px;
  flex-wrap: wrap;
}
.btn {
  display: inline-block;
  padding: 14px 26px;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform var(--t-fast), box-shadow var(--t-fast), filter var(--t-fast);
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #ffaa00);
  color: #1a1a1a;
  box-shadow: 0 8px 22px -6px rgba(255,203,5,0.6);
}
.btn.primary:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn.ghost {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-line);
  color: var(--ink);
}
.btn.ghost:hover { background: rgba(255,255,255,0.1); }

/* ---------------- Card modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 4, 14, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease-out);
}
.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(320px, 480px);
  gap: 32px;
  background: linear-gradient(180deg, rgba(28, 32, 78, 0.95) 0%, rgba(12, 16, 50, 0.95) 100%);
  border: 1px solid var(--panel-line);
  border-radius: 22px;
  padding: 28px;
  max-width: 920px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.8);
  transform: scale(0.95) translateY(12px);
  transition: transform var(--t-base) var(--ease-out);
}
.modal-backdrop.active .modal { transform: scale(1) translateY(0); }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 36px; height: 36px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
  transition: background var(--t-fast), transform var(--t-fast);
}
.modal-close:hover { background: rgba(255,255,255,0.18); transform: rotate(90deg); }

.modal-card-wrap {
  display: flex; align-items: center; justify-content: center;
  perspective: 1200px;
}
.modal-card {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 240 / 336;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  cursor: grab;
  transform-style: preserve-3d;
  transform:
    perspective(900px)
    rotateX(var(--rx, 0deg))
    rotateY(var(--ry, 0deg));
  transition: transform var(--t-base) var(--ease-out);
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.08);
}
.modal-card img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  opacity: 1;
  transition: opacity 180ms ease-in;
}
/* Placeholder shown while the next card image decodes — uses the same
   back.webp as the deck back so the loading state matches the card flip. */
.modal-card.loading {
  background: url('../images/back.webp') center / cover no-repeat, #0c1748;
}
.modal-card.loading::after,
.modal-card.loading::before {
  /* Hide holo overlays during loading */
  opacity: 0 !important;
}
.modal-card.loading img { opacity: 0; }

/* Holo glare on the modal card */
.modal-card::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(farthest-corner circle at var(--mx, 50%) var(--my, 50%),
    rgba(255,255,255,0.7) 8%, rgba(255,255,255,0.15) 18%, transparent 35%);
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
  z-index: 2;
}
.modal-card.holo::before { opacity: 1; }
.modal-card::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.4) 50%, transparent 70%),
    repeating-linear-gradient(115deg, #ff80ff 0%, #80c0ff 14%, #80ffc0 29%, #ffe080 43%, #ff80c0 57%, #ff80ff 71%, #80c0ff 86%);
  background-size: 200% 200%, 250% 250%;
  background-position: var(--bx, 50%) var(--by, 50%), 0 0;
  mix-blend-mode: color-dodge;
  opacity: 0;
  transition: opacity var(--t-fast);
  pointer-events: none;
  z-index: 1;
}
.modal-card.holo::after { opacity: var(--holo-strength, 0.45); }
.modal-card.r-rare   { --holo-strength: 0.3; }
.modal-card.r-ultra  { --holo-strength: 0.55; }
.modal-card.r-secret { --holo-strength: 0.7;  }
.modal-card.r-chase  { --holo-strength: 0.85; }

/* Right-side info panel */
.modal-info {
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.modal-info::-webkit-scrollbar { width: 6px; }
.modal-info::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.modal-name {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
}
.modal-name .hp {
  font-size: 16px;
  color: var(--accent-3);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.modal-tagline {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin-bottom: 14px;
}
.modal-rarity-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 18px;
}
.rarity-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.08);
  color: var(--ink);
  border: 1px solid var(--panel-line);
}
.rarity-pill.r-uncommon { background: linear-gradient(135deg, var(--rare-uncommon), #2a8e3a); color: #fff; border-color: transparent; }
.rarity-pill.r-rare     { background: linear-gradient(135deg, var(--rare-rare), #2a4d8e); color: #fff; border-color: transparent; }
.rarity-pill.r-ultra    { background: linear-gradient(135deg, var(--accent-5), #5d3aa2); color: #fff; border-color: transparent; }
.rarity-pill.r-secret   { background: linear-gradient(135deg, #ffd34d, #ff8c00); color: #1a1a1a; border-color: transparent; }
.rarity-pill.r-chase    { background: linear-gradient(135deg, var(--rare-chase), #6a1aff); color: #fff; border-color: transparent; }

.type-chips {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.type-chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--type-color, #6a7080);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.type-Grass    { --type-color: #6cba4a; }
.type-Fire     { --type-color: #ff7a1f; }
.type-Water    { --type-color: #3a8ce0; }
.type-Lightning { --type-color: #f5cc1a; color: #1a1a1a; text-shadow: none; }
.type-Psychic  { --type-color: #b045c4; }
.type-Fighting { --type-color: #c04a36; }
.type-Darkness { --type-color: #4a3c5a; }
.type-Metal    { --type-color: #8c8caa; }
.type-Fairy    { --type-color: #ee70c0; }
.type-Dragon   { --type-color: #c4a93d; color: #1a1a1a; text-shadow: none; }
.type-Colorless { --type-color: #c8c8c8; color: #1a1a1a; text-shadow: none; }

.modal-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-line);
}
.modal-section h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
}

.attack {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.attack-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.attack-name { font-weight: 700; font-size: 15px; }
.attack-cost {
  display: inline-flex; gap: 3px; flex-wrap: wrap;
}
.attack-cost .energy {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--type-color, #6a7080);
  display: inline-block;
  border: 1.5px solid rgba(0,0,0,0.4);
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.3);
}
.attack-damage {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
}
.attack-effect {
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.45;
}

.ability {
  background: linear-gradient(135deg, rgba(255, 92, 240, 0.08), rgba(180, 108, 255, 0.04));
  border: 1px solid rgba(255, 92, 240, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.ability-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
}
.ability-tag {
  font-size: 9px;
  letter-spacing: 0.16em;
  font-weight: 700;
  padding: 3px 7px;
  background: linear-gradient(135deg, var(--rare-chase), #6a1aff);
  border-radius: 4px;
  color: #fff;
}
.ability-name { font-weight: 700; font-size: 15px; color: var(--rare-chase); }
.ability-effect { font-size: 13px; color: var(--ink-dim); line-height: 1.45; }

.modal-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-line);
  font-size: 12px;
  color: var(--ink-faint);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
}
.modal-footer span strong { color: var(--ink); font-weight: 600; }

/* Mobile: stack the modal */
@media (max-width: 760px) {
  .modal {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 20px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
  }
  .modal-card { max-width: 240px; margin: 0 auto; }
}

/* Make summary cards clearly clickable */
.summary-card { user-select: none; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translate(-50%, 20px);
  padding: 12px 18px;
  background: rgba(20, 24, 60, 0.95);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  color: var(--ink);
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
  z-index: 100;
  backdrop-filter: blur(8px);
}
.toast.active { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Misc ---------------- */
[hidden] { display: none !important; }
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-dim);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
