/* Card system styles (v14) */

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }

/* ============ card frame ============ */
/* 9:16 to match phone screens. Images generated before this change are 2:3 and
   get their sides trimmed by object-fit:cover — acceptable for centred portraits. */
.card-frame {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  overflow: hidden;
  background: #181b22;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s;
  border: 2px solid var(--border);
}
.card-frame:hover { transform: translateY(-4px); }
.card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; transition: transform 0.1s; }
.card-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1f232c, #2a2f3a);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 12px;
  z-index: 1;
}
.card-badge {
  position: absolute; top: 8px; left: 8px; z-index: 5;
  background: rgba(0,0,0,0.7); color: #fff; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
}
.card-name {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 4;
  padding: 12px 10px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.88));
  color: #fff;
}
.card-name b { display: block; font-size: 14px; }
.card-name span { font-size: 11px; color: rgba(255,255,255,0.7); }

/* rarity frames */
.card-frame.rarity-C { border-color: #888; }
.card-frame.rarity-B { border-color: #6aa9ff; box-shadow: 0 0 12px rgba(106,169,255,0.25); }
.card-frame.rarity-A { border-color: #ffd166; box-shadow: 0 0 18px rgba(255,209,102,0.4); }
.card-frame.rarity-S { border-color: #ff9466; box-shadow: 0 0 24px rgba(255,148,102,0.55); }
.card-frame.rarity-UR { border-color: #ff6bff; box-shadow: 0 0 30px rgba(255,107,255,0.6), inset 0 0 30px rgba(255,107,255,0.2); }

.card-badge.rarity-C { background: rgba(136,136,136,0.85); }
.card-badge.rarity-B { background: rgba(106,169,255,0.85); }
.card-badge.rarity-A { background: rgba(255,209,102,0.85); color: #1a1500; }
.card-badge.rarity-S { background: linear-gradient(45deg, #ffd166, #ff9466); color: #2a0e00; }
.card-badge.rarity-UR { background: linear-gradient(45deg, #ff6bff, #6aa9ff, #7ee0c6); background-size: 200% 200%; color: #fff; animation: badgeShift 3s infinite linear; }
@keyframes badgeShift { 0% { background-position: 0 0; } 100% { background-position: 200% 200%; } }

/* rarity fx overlays */
.rarity-fx { position: absolute; inset: 0; pointer-events: none; z-index: 3; mix-blend-mode: screen; }
.rarity-fx.supreme {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,215,128,0.5), transparent 35%),
    radial-gradient(circle at 70% 70%, rgba(255,180,90,0.4), transparent 40%);
  animation: shimmerS 5s infinite linear;
}
@keyframes shimmerS {
  0% { background-position: 0 0, 100% 100%; }
  100% { background-position: 100% 100%, 0 0; }
}
.rarity-fx.ur {
  background:
    linear-gradient(115deg, transparent 30%, rgba(255,107,255,0.45) 45%, rgba(106,169,255,0.45) 55%, transparent 70%),
    radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.5), transparent 35%);
  background-size: 200% 200%, auto;
  animation: shimmerUR 4s infinite linear;
  filter: hue-rotate(0deg);
}
@keyframes shimmerUR {
  0% { background-position: 0 0, 0 0; filter: hue-rotate(0deg); }
  100% { background-position: 200% 200%, 0 0; filter: hue-rotate(360deg); }
}

/* ============ fullscreen view ============ */
.fullscreen-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 99999;
  display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(14px, 4vw, 24px);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.fs-close {
  position: fixed; top: 16px; right: 16px; z-index: 100001;
  background: transparent; color: #fff; border: 1px solid #444; border-radius: 50%;
  width: 44px; height: 44px; font-size: 18px; cursor: pointer;
}
.fullscreen-card {
  display: grid; grid-template-columns: minmax(280px, 480px) 1fr; gap: 24px;
  max-width: 1000px; width: 100%; background: var(--panel); border-radius: 16px;
  padding: 20px; border: 2px solid var(--border);
}
.fullscreen-card.rarity-S { border-color: #ff9466; box-shadow: 0 0 40px rgba(255,148,102,0.5); }
.fullscreen-card.rarity-UR { border-color: #ff6bff; box-shadow: 0 0 60px rgba(255,107,255,0.65); }
.fs-image-wrap { position: relative; aspect-ratio: 9/16; border-radius: 12px; overflow: hidden; background: #0a0d12; }
.fs-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.fs-image-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }
.fs-badge { position: absolute; top: 12px; left: 12px; z-index: 5; padding: 4px 12px; border-radius: 999px; font-weight: 800; letter-spacing: 0.1em; font-size: 13px; color: #fff; }
.fs-badge.rarity-C { background: rgba(136,136,136,0.9); }
.fs-badge.rarity-B { background: rgba(106,169,255,0.9); }
.fs-badge.rarity-A { background: rgba(255,209,102,0.9); color: #1a1500; }
.fs-badge.rarity-S { background: linear-gradient(45deg, #ffd166, #ff9466); color: #2a0e00; }
.fs-badge.rarity-UR { background: linear-gradient(45deg, #ff6bff, #6aa9ff, #7ee0c6); animation: badgeShift 3s infinite linear; }
.fs-info { color: var(--text); display: flex; flex-direction: column; gap: 12px; }
.fs-title h2 { margin: 0; font-size: 24px; }
.fs-subtitle { color: var(--accent-2); font-size: 14px; margin-top: 4px; }
.fs-lore { color: var(--muted); font-size: 13px; line-height: 1.6; }
.fs-stats .stat-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 6px 0; }
.fs-stats .stat-label { min-width: 70px; flex-shrink: 0; color: var(--muted); }
.fs-stats .stat-bar { flex: 1; height: 8px; background: #2a2f3a; border-radius: 4px; overflow: hidden; }
.fs-stats .stat-bar > div { height: 100%; background: linear-gradient(90deg, #6aa9ff, #7ee0c6); border-radius: 4px; }
.fs-stats .stat-val { width: 32px; text-align: right; color: var(--text); }
.fs-flavor { font-style: italic; color: var(--accent); font-size: 13px; }
@media (max-width: 700px) {
  .fullscreen-card { grid-template-columns: 1fr; }
}

/* ============ gacha modal ============ */
.gacha-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 99998;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gacha-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: clamp(18px, 5vw, 28px); width: min(90vw, 360px); text-align: center;
}
.gacha-panel select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); padding: 8px 10px; border-radius: 8px; }

.gacha-stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; padding: clamp(16px, 5vw, 40px);
}
.gacha-capsule {
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffd166, #ff6bff 70%, #6aa9ff);
  position: relative; animation: capsuleSpin 2s linear infinite;
  box-shadow: 0 0 40px rgba(255, 215, 128, 0.6);
}
.capsule-inner {
  position: absolute; inset: 12px; border-radius: 50%;
  background: radial-gradient(circle at 60% 40%, rgba(255,255,255,0.8), transparent 35%);
}
@keyframes capsuleSpin {
  0%   { transform: rotate(0) scale(1);   filter: hue-rotate(0deg); }
  50%  { transform: rotate(180deg) scale(1.08); filter: hue-rotate(180deg); }
  100% { transform: rotate(360deg) scale(1); filter: hue-rotate(360deg); }
}
.gacha-sparkles { position: relative; width: 200px; height: 0; }
.gacha-sparkles i {
  position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #ffeb8c;
  box-shadow: 0 0 8px #fff;
  animation: sparkle 1.8s infinite ease-in-out;
}
.gacha-sparkles i:nth-child(1) { left: 10%; top: -80px; animation-delay: 0s; }
.gacha-sparkles i:nth-child(2) { left: 30%; top: -50px; animation-delay: 0.2s; }
.gacha-sparkles i:nth-child(3) { left: 55%; top: -90px; animation-delay: 0.4s; }
.gacha-sparkles i:nth-child(4) { left: 80%; top: -60px; animation-delay: 0.6s; }
.gacha-sparkles i:nth-child(5) { left: 95%; top: -40px; animation-delay: 0.8s; }
.gacha-sparkles i:nth-child(6) { left: 5%;  top: -110px; animation-delay: 1.0s; }
.gacha-sparkles i:nth-child(7) { left: 45%; top: -30px; animation-delay: 1.2s; }
.gacha-sparkles i:nth-child(8) { left: 65%; top: -70px; animation-delay: 1.4s; }
.gacha-sparkles i:nth-child(9) { left: 20%; top: -100px; animation-delay: 1.6s; }
.gacha-sparkles i:nth-child(10) { left: 75%; top: -120px; animation-delay: 0.5s; }
.gacha-sparkles i:nth-child(11) { left: 50%; top: -130px; animation-delay: 1.1s; }
.gacha-sparkles i:nth-child(12) { left: 35%; top: -140px; animation-delay: 1.5s; }
@keyframes sparkle { 0%,100% { opacity: 0; transform: scale(0.5); } 50% { opacity: 1; transform: scale(1.4); } }
.gacha-status { color: var(--accent-2); font-weight: 700; letter-spacing: 0.05em; font-size: 16px; }

.gacha-stage.error { color: var(--bad); }

/* reveal */
.gacha-reveal {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.reveal-meta { color: var(--accent-2); font-weight: 800; letter-spacing: 0.1em; }
/* Driven by height so the taller 9:16 card still fits above the close button on
   a phone; max-width caps it on narrow screens. */
.reveal-slot { height: min(68vh, 560px); aspect-ratio: 9 / 16; max-width: 84vw; }
.reveal-slot .card-frame { width: 100%; height: 100%; animation: dropIn 0.7s cubic-bezier(0.2, 1, 0.4, 1); }
.gacha-reveal.rarity-S .reveal-slot .card-frame { animation: dropInGlow 0.9s cubic-bezier(0.2, 1, 0.4, 1); }
.gacha-reveal.rarity-UR .reveal-slot .card-frame { animation: dropInBig 1.2s cubic-bezier(0.15, 1.05, 0.35, 1); }
@keyframes dropIn { 0% { transform: scale(0.6) rotate(-8deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes dropInGlow { 0% { transform: scale(0.5) rotate(-6deg); opacity: 0; filter: brightness(2); } 100% { transform: scale(1) rotate(0); opacity: 1; filter: brightness(1); } }
@keyframes dropInBig { 0% { transform: scale(0.3) rotate(-12deg); opacity: 0; filter: brightness(2.5) saturate(1.5); } 50% { transform: scale(1.1) rotate(2deg); opacity: 1; filter: brightness(1.4); } 100% { transform: scale(1) rotate(0); opacity: 1; filter: brightness(1); } }
.reveal-actions button { background: var(--accent); color: #0a0d12; border: none; padding: 10px 22px; border-radius: 8px; font-weight: 700; cursor: pointer; }

/* rarity-based reveal FX overlays */
.reveal-flash {
  position: fixed; inset: 0; z-index: 99999; pointer-events: none;
  background: radial-gradient(circle at center, #fff 0%, rgba(255,255,255,0.5) 30%, transparent 70%);
}
.reveal-flash.s { animation: flashBurstS 400ms ease-out forwards; }
.reveal-flash.ur { animation: flashBurstUR 600ms ease-out forwards; }
@keyframes flashBurstS {
  0% { opacity: 0; transform: scale(0.3); }
  20% { opacity: 0.85; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.5); }
}
@keyframes flashBurstUR {
  0% { opacity: 0; transform: scale(0.2); filter: hue-rotate(0deg); }
  15% { opacity: 1; transform: scale(1.2); filter: hue-rotate(60deg); }
  100% { opacity: 0; transform: scale(2); filter: hue-rotate(360deg); }
}
.reveal-rays {
  position: fixed; inset: -50%; z-index: 99998; pointer-events: none;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(255,107,255,0.35) 10deg, transparent 20deg, rgba(106,169,255,0.35) 30deg, transparent 40deg, rgba(126,224,198,0.35) 50deg, transparent 60deg, rgba(255,209,102,0.35) 70deg, transparent 80deg, transparent 360deg);
  animation: rayBurst 1.8s linear forwards;
  mix-blend-mode: screen;
}
@keyframes rayBurst {
  0% { transform: rotate(0deg) scale(0.5); opacity: 0; }
  20% { opacity: 0.9; }
  100% { transform: rotate(720deg) scale(1.5); opacity: 0; }
}
.gacha-backdrop.shake { animation: screenShake 0.6s ease-in-out; }
@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 4px); }
  40% { transform: translate(8px, -6px); }
  60% { transform: translate(-4px, 8px); }
  80% { transform: translate(6px, -4px); }
}

/* admin */
.ghost-link { color: var(--muted); font-size: 12px; margin-right: 8px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 6px; text-decoration: none; }
.ghost-link:hover { color: var(--text); border-color: var(--accent); }
