/* ================= RUGSWEEPER: shareable cards (reveal overlay + binder) ================= */

.rsc,
.rsc-binder {
  --rc: #c9d3dc;
  --rg: #9fb3c8;
  --holo: 0;
  --mx: 50%;
  --my: 50%;
  --tilt: 0;
  position: fixed;
  inset: 0;
  z-index: 65; /* over the post-match screen (46) and the profile panel (60) */
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  color: #fff;
  font-family: "Michroma", "Eurostile", Arial, sans-serif;
}

/* ---------- reveal layout ---------- */

.rsc {
  --cw: min(calc(100vw - 40px), calc((100vh - 250px) * 0.8), 470px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.2vh, 22px);
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

@supports (height: 100dvh) {
  .rsc {
    --cw: min(calc(100vw - 40px - env(safe-area-inset-left) - env(safe-area-inset-right)),
        calc((100dvh - 250px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 0.8), 470px);
  }
}

.rsc-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 46%, color-mix(in srgb, var(--rg) 20%, transparent), transparent 70%),
    radial-gradient(ellipse at 50% 50%, rgba(6, 9, 12, 0.82), rgba(1, 2, 3, 0.97) 75%);
  -webkit-backdrop-filter: blur(10px) saturate(0.6);
  backdrop-filter: blur(10px) saturate(0.6);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.rsc.in .rsc-bg { opacity: 1; }

.rsc-bg::after {
  /* scanline grit */
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.rsc-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.rsc-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  background: radial-gradient(circle at 50% 46%, #fff 0%, color-mix(in srgb, var(--rc) 70%, #fff) 22%, transparent 65%);
  mix-blend-mode: screen;
}

/* ---------- title ---------- */

.rsc-top {
  position: relative;
  z-index: 2;
  text-align: center;
  min-height: 58px;
}

.rsc-kicker {
  font-size: 11px;
  letter-spacing: 0.32em;
  color: rgba(255, 255, 255, 0.6);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.4s ease 0.2s, transform 0.4s ease 0.2s;
}

.rsc.in .rsc-kicker { opacity: 1; transform: none; }

.rsc-title {
  margin-top: 8px;
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: clamp(26px, 4.4vh, 40px);
  line-height: 1;
  letter-spacing: 0.28em;
  padding-left: 0.28em;
  color: #fff;
  background: linear-gradient(180deg, #fff 0%, color-mix(in srgb, var(--rc) 55%, #fff) 50%, var(--rc) 51%, color-mix(in srgb, var(--rc) 60%, #fff) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--rg) 70%, transparent)) drop-shadow(0 3px 0 rgba(0, 0, 0, 0.7));
  opacity: 0;
}

.rsc.revealed .rsc-title { opacity: 1; }

/* ---------- stage + card ---------- */

.rsc-stage {
  position: relative;
  z-index: 2;
  width: var(--cw);
  height: calc(var(--cw) * 1.25);
  flex: none;
  perspective: 1400px;
}

.rsc-rays {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 260vmax;
  height: 260vmax;
  margin: -130vmax 0 0 -130vmax;
  pointer-events: none;
  background: repeating-conic-gradient(from 0deg,
      color-mix(in srgb, var(--rc) 0%, transparent) 0deg 5deg,
      color-mix(in srgb, var(--rc) 26%, transparent) 7deg 9deg,
      color-mix(in srgb, var(--rc) 0%, transparent) 11deg 15deg);
  -webkit-mask-image: radial-gradient(circle, #000 2%, rgba(0, 0, 0, 0.5) 12%, transparent 30%);
  mask-image: radial-gradient(circle, #000 2%, rgba(0, 0, 0, 0.5) 12%, transparent 30%);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.8s ease, transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  animation: rsc-spin 60s linear infinite;
  filter: saturate(0.2);
}

.rsc.in .rsc-rays { opacity: 0.35; transform: scale(0.85); }
.rsc.charging .rsc-rays { opacity: 0.6; transform: scale(0.95); }
.rsc.revealed .rsc-rays { opacity: 1; transform: scale(1); filter: none; }
.rsc.r-common.revealed .rsc-rays { opacity: 0.55; }

@keyframes rsc-spin { to { rotate: 360deg; } }

.rsc-shadow {
  position: absolute;
  left: 50%;
  bottom: calc(var(--cw) * -0.09);
  width: 80%;
  height: calc(var(--cw) * 0.1);
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.75), transparent 70%);
  filter: blur(6px);
  opacity: 0;
  transition: opacity 0.6s ease 0.4s;
}

.rsc.in .rsc-shadow { opacity: 1; }

.rsc-float,
.rsc-jitter,
.rsc-card,
.rsc-flip {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.rsc-float { opacity: 0; }
.rsc.is-instant.in .rsc-float { opacity: 1; }

.rsc-aura {
  position: absolute;
  inset: -18%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--rg) 80%, transparent), color-mix(in srgb, var(--rc) 25%, transparent) 55%, transparent 75%);
  filter: blur(18px);
  opacity: 0;
  pointer-events: none;
}

.rsc.in .rsc-aura { opacity: 0.12; transition: opacity 0.6s ease 0.5s; }

.rsc.revealed .rsc-aura { opacity: 0.55; animation: rsc-pulse 2.4s ease-in-out infinite; }
.rsc.r-common.revealed .rsc-aura { opacity: 0.25; }

@keyframes rsc-pulse {
  50% { opacity: 0.85; scale: 1.06; }
}

.rsc-card { will-change: transform; cursor: grab; }

.rsc-face {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--cw) * 0.043);
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 30px 60px -10px rgba(0, 0, 0, 0.85),
    0 0 calc(var(--cw) * 0.12) color-mix(in srgb, var(--rg) 30%, transparent);
  background: #040506;
}

.rsc-front { transform: rotateY(180deg); }

.rsc-back-art {
  position: absolute;
  inset: 0;
  background: #0b2a18 center / cover no-repeat;
}

.rsc-charge {
  position: absolute;
  inset: 0;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.95), color-mix(in srgb, var(--rc) 85%, transparent) 25%, transparent 70%),
    linear-gradient(0deg, color-mix(in srgb, var(--rc) 50%, transparent), transparent 60%);
  mix-blend-mode: screen;
  box-shadow: inset 0 0 calc(var(--cw) * 0.12) var(--rc);
}

.rsc.charging .rsc-back { box-shadow: 0 0 0 2px var(--rc), 0 0 calc(var(--cw) * 0.2) var(--rg), 0 30px 60px -10px #000; }

.rsc-front-art,
.rsc-front-art canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* holographic layers */
.rsc-holo {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(115deg,
      #ff3b4a 0%, #ffd21a 4%, #2fe07a 8%, #3fa9ff 12%, #b06bff 16%, #ff3b4a 20%);
  background-size: 260% 260%;
  background-position: var(--mx) var(--my);
  mix-blend-mode: color-dodge;
  opacity: calc(var(--holo) * (0.45 + var(--tilt) * 0.9));
  filter: brightness(0.55) contrast(1.6) saturate(1.3);
  -webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.5) 40%, rgba(0, 0, 0, 0.2) 80%);
  mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, rgba(0, 0, 0, 0.5) 40%, rgba(0, 0, 0, 0.2) 80%);
}

.rsc.r-legendary .rsc-holo { animation: rsc-hue 6s linear infinite; }

@keyframes rsc-hue { to { filter: brightness(0.55) contrast(1.6) saturate(1.3) hue-rotate(360deg); } }

.rsc-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.0) 38%, rgba(255, 255, 255, 0.42) 46%, rgba(255, 255, 255, 0.0) 54%, transparent 62%);
  background-size: 250% 250%;
  background-position: calc(100% - var(--mx)) var(--my);
  mix-blend-mode: overlay;
  opacity: 0.8;
}

.rsc-glare {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, 0.32), transparent 48%);
  mix-blend-mode: soft-light;
}

/* ---------- actions ---------- */

.rsc-actions {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 760px;
  min-height: 44px;
  pointer-events: none;
}

.rsc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(30, 36, 44, 0.86), rgba(10, 13, 17, 0.92));
  color: #eef3f6;
  font: 600 14px/1 "Oswald", "Arial Narrow", sans-serif;
  letter-spacing: 0.1em;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 20px -8px rgba(0, 0, 0, 0.8);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}

.rsc-btn svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rsc-btn svg.fill { fill: currentColor; stroke: none; }

.rsc-btn:hover,
.rsc-btn:focus-visible {
  border-color: var(--rc);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 0 1px var(--rc), 0 0 22px -4px var(--rg);
  outline: none;
  transform: translateY(-1px);
}

.rsc-btn:active { transform: translateY(1px) scale(0.98); }

.rsc-btn.primary {
  color: #050607;
  border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--rc) 65%, #fff), var(--rc) 55%, color-mix(in srgb, var(--rc) 75%, #000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 0 26px -6px var(--rg), 0 10px 22px -10px #000;
}

.rsc.r-common .rsc-btn.primary { --rc: #2fe07a; --rg: #2fe07a; }

.rsc-btn.primary:hover,
.rsc-btn.primary:focus-visible { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 0 0 2px #fff, 0 0 30px -2px var(--rg); }

.rsc-btn.ghost { background: transparent; color: rgba(255, 255, 255, 0.7); }

.rsc-actions .rsc-btn {
  opacity: 0;
  transform: translateY(18px);
}

.rsc.done .rsc-actions { pointer-events: auto; }

.rsc.done .rsc-actions .rsc-btn {
  opacity: 1;
  transform: none;
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.rsc.done .rsc-actions .rsc-btn:nth-child(2) { transition-delay: 0.05s, 0.05s, 0s, 0s, 0s; }
.rsc.done .rsc-actions .rsc-btn:nth-child(3) { transition-delay: 0.1s, 0.1s, 0s, 0s, 0s; }
.rsc.done .rsc-actions .rsc-btn:nth-child(4) { transition-delay: 0.15s, 0.15s, 0s, 0s, 0s; }
.rsc.done .rsc-actions .rsc-btn:nth-child(5) { transition-delay: 0.2s, 0.2s, 0s, 0s, 0s; }
.rsc.done .rsc-actions .rsc-btn:nth-child(6) { transition-delay: 0.25s, 0.25s, 0s, 0s, 0s; }
.rsc.done .rsc-actions .rsc-btn:hover { transform: translateY(-1px); }

.rsc-hint {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.4);
  pointer-events: none;
  animation: rsc-blink 1.6s ease-in-out infinite;
  transition: opacity 0.3s;
}

.rsc.done .rsc-hint,
.rsc.is-instant .rsc-hint { opacity: 0; animation: none; }

@keyframes rsc-blink { 50% { opacity: 0.4; } }

.rsc-toast {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 4px);
  transform: translate(-50%, 16px);
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(8, 12, 16, 0.94);
  border: 1px solid var(--rc);
  box-shadow: 0 0 24px -6px var(--rg), 0 12px 30px -10px #000;
  font: 500 15px/1.2 "Oswald", sans-serif;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.rsc-toast.on { opacity: 1; transform: translate(-50%, 0); }
.rsc-toast.bad { border-color: #ff3b4a; box-shadow: 0 0 24px -6px #ff3b4a, 0 12px 30px -10px #000; }

/* ---------- exit ---------- */

.rsc.out .rsc-bg,
.rsc.out .rsc-top,
.rsc.out .rsc-actions,
.rsc.out .rsc-rays { opacity: 0; transition: opacity 0.25s ease; }

.rsc.out .rsc-stage { transition: transform 0.28s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.28s ease; transform: translateY(30px) scale(0.92); opacity: 0; }
.rsc.out .rsc-fx { opacity: 0; transition: opacity 0.2s; }

/* ---------- phone ---------- */

@media (max-width: 560px) {
  .rsc { gap: 12px; }
  .rsc-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: min(100%, 420px);
    gap: 7px;
  }
  .rsc-actions .rsc-btn { padding: 0 8px; font-size: 13px; letter-spacing: 0.06em; gap: 6px; }
  .rsc-actions .rsc-btn.primary { grid-column: span 2; }
  .rsc-actions .rsc-btn svg { width: 15px; height: 15px; }
  .rsc-kicker { font-size: 10px; }
}

@media (max-height: 640px) {
  .rsc-kicker { display: none; }
  .rsc-top { min-height: 34px; }
}

.rsc.no-motion *,
.rsc-binder.no-motion * { animation: none !important; transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  .rsc *, .rsc-binder * { animation: none !important; transition-duration: 0.01ms !important; }
}

/* ---------- binder ---------- */

.rsc-binder {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(47, 224, 122, 0.12), transparent 60%),
    rgba(3, 5, 7, 0.96);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  opacity: 0;
  transition: opacity 0.22s ease;
  touch-action: pan-y;
}

.rsc-binder.in { opacity: 1; }
.rsc-binder.out { opacity: 0; }

.rsb-head {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto 14px;
}

.rsb-head > div:first-child { flex: 1; min-width: 0; }
.rsb-kicker { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10px; letter-spacing: 0.3em; color: #ffd21a; }
.rsb-title { font-family: "Archivo Black", Impact, sans-serif; font-size: clamp(22px, 4vw, 34px); letter-spacing: 0.06em; margin-top: 4px; }
.rsb-count { font: 500 18px "Oswald", sans-serif; color: rgba(255, 255, 255, 0.55); }
.rsb-count b { color: #fff; font-weight: 700; font-size: 26px; }
.rsb-close { --rc: #2fe07a; --rg: #2fe07a; }

.rsb-grid {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 4px calc(24px + env(safe-area-inset-bottom));
  align-content: start;
}

@media (max-width: 560px) {
  .rsb-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

.rsb-card {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  perspective: 800px;
  touch-action: manipulation;
  min-width: 0;
}

.rsb-art {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 9px;
  overflow: hidden;
  background: #0b1014 center / cover no-repeat;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 14px 30px -12px #000;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

.rsb-art canvas { width: 100%; height: 100%; display: block; }

.rsb-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.22) 50%, transparent 65%);
  background-size: 250% 250%;
  background-position: 100% 0;
  mix-blend-mode: overlay;
  transition: background-position 0.6s ease;
}

.rsb-card:hover .rsb-art,
.rsb-card:focus-visible .rsb-art {
  transform: translateY(-6px) rotateX(6deg) scale(1.03);
  box-shadow: 0 0 0 2px var(--rc), 0 0 30px -6px var(--rg), 0 22px 40px -14px #000;
}

.rsb-card:hover .rsb-art::after,
.rsb-card:focus-visible .rsb-art::after { background-position: 0 100%; }

.rsb-card:focus-visible { outline: none; }

.rsb-card.locked { cursor: default; }
.rsb-card.locked .rsb-art { filter: grayscale(0.85) brightness(0.45); }
.rsb-card.locked .rsb-art::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 46%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: url("../images/icons/ui-lock.webp") center / contain no-repeat;
  filter: drop-shadow(0 4px 10px #000) brightness(1.6);
}

.rsb-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
  font: 600 13px/1.2 "Oswald", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rsb-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsb-label i { font: 400 8px "Michroma", sans-serif; letter-spacing: 0.18em; color: var(--rc); flex: none; font-style: normal; }
.rsb-card.locked .rsb-label { color: rgba(255, 255, 255, 0.35); }
.rsb-card.locked .rsb-label i { color: rgba(255, 255, 255, 0.35); }
