/* ---------- the rip room: slide to rip → ember → rise → float → bloom → shards → settle ---------- */
:root {
  --magenta: #ff2d9b;
  --magenta-deep: #8f0c4a;
  --rip-red: #7a0f3a;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.2, 0.9, 0.3, 1.15);
  --t-fade: 220ms;
  --t-ignite: 360ms;
  --t-rise: 900ms;
  --t-float: 1800ms;
  --t-burst: 520ms;
  --t-shards: 450ms;
  --t-settle: 1200ms;
}
body.rip-open { overflow: hidden; }
#rip { position: fixed; inset: 0; z-index: 100; color: var(--ink); overflow: hidden; background: #000; }
#rip[hidden] { display: none; }

/* layers */
.rip-bg { position: absolute; inset: 0; background: radial-gradient(60% 40% at 50% 0%, rgba(255,210,120,0.22), transparent 70%), #0e0f13; transition: background 600ms linear; }
.rip-spokes { position: absolute; left: 50%; top: 46%; width: 200vmax; height: 200vmax; transform: translate(-50%, -50%) rotate(0deg); opacity: 0; pointer-events: none;
  background: repeating-conic-gradient(from 0deg, transparent 0deg 9deg, rgba(255,255,255,0) 9deg 10.5deg, rgba(255,255,255,0.85) 10.5deg 11.2deg, transparent 11.2deg 24deg);
  mask: radial-gradient(circle at center, transparent 0 10%, #000 22%, transparent 60%); -webkit-mask: radial-gradient(circle at center, transparent 0 10%, #000 22%, transparent 60%);
  filter: blur(0.6px); transition: opacity 500ms linear; }
.rip-spokes.two { background: repeating-conic-gradient(from 7deg, transparent 0deg 14deg, rgba(255,255,255,0.5) 14deg 14.6deg, transparent 14.6deg 31deg); }
.rip-flare { position: absolute; width: 180px; height: 180px; border-radius: 50%; opacity: 0; pointer-events: none; filter: blur(8px); transition: opacity 600ms, transform 800ms, top 800ms; }
.rip-flare.a { left: 50%; top: 72%; transform: translate(-50%, -50%); background: radial-gradient(circle, rgba(255,255,255,0.9), rgba(255,80,160,0.55) 30%, transparent 65%); }
.rip-flare.b { left: 50%; top: 20%; transform: translate(-50%, -50%) scale(0.6); background: radial-gradient(circle, rgba(255,255,255,0.7), rgba(120,160,255,0.4) 35%, transparent 65%); }
.rip-bloom { position: absolute; left: 50%; top: 46%; width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, -50%) scale(0); background: radial-gradient(circle, #fff 0 30%, var(--magenta) 55%, transparent 72%); opacity: 0; pointer-events: none; z-index: 3; }
#rip-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }

.rip-top { position: absolute; inset: 14px 16px auto; z-index: 8; display: flex; justify-content: space-between; align-items: center; }
.rip-x { width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.18); background: rgba(20,20,24,0.8); color: #fff; font-size: 20px; cursor: pointer; }
.rip-x:focus-visible, .rq:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.rip-chip { padding: 8px 12px; border-radius: 999px; background: rgba(20,20,24,0.8); border: 1px solid rgba(255,255,255,0.18); color: var(--ink-2); }

/* scene: pack + card */
.rip-scene { position: absolute; inset: 0; z-index: 4; pointer-events: none; perspective: 1200px; }
.rip-pack-wrap { position: absolute; left: 50%; top: 32%; width: min(50vw, 220px); aspect-ratio: 2 / 3; transform: translate(-50%, -50%); transform-style: preserve-3d; }
.rip-spot { position: absolute; left: 50%; top: -30%; width: 160%; height: 60%; transform: translateX(-50%); background: radial-gradient(50% 60% at 50% 100%, rgba(255,215,130,0.35), transparent 70%); filter: blur(4px); transition: opacity 300ms; }
.rip-pack { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 30px 40px rgba(0,0,0,0.8)); animation: idlehover 4.5s ease-in-out infinite; transform-origin: 50% 55%; }
@keyframes idlehover { 0%, 100% { transform: translateY(0) rotateY(-6deg); } 50% { transform: translateY(-10px) rotateY(6deg); } }
.rip-card { position: absolute; left: 50%; top: 46%; width: min(66vw, 300px); aspect-ratio: 3 / 4; transform: translate(-50%, -50%) scale(0.2) rotateX(40deg) rotateY(-30deg); opacity: 0; border-radius: 12px; overflow: hidden; box-shadow: 0 60px 100px rgba(0,0,0,0.6), 0 0 80px rgba(255,120,180,0.35); background: #fff; }
.rip-card img { width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; }
.rip-card .glare { position: absolute; inset: 0; background: radial-gradient(circle at var(--gx, 50%) var(--gy, 40%), rgba(255,255,255,0.4), transparent 55%); mix-blend-mode: screen; pointer-events: none; }

/* sheets */
.rip-sheet { position: absolute; inset: auto 0 0; z-index: 7; padding: 0 20px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; transition: opacity var(--t-fade) linear, transform var(--t-fade) linear; }
.rip-sheet[hidden] { display: none; }
.rip-sheet h3 { margin: 0; font: 500 clamp(18px, 2.6vw, 24px)/1.15 var(--sans); letter-spacing: -0.01em; text-transform: uppercase; }
.rip-sub { margin: -4px 0 0; font-size: 12px; color: var(--muted); }
.rip-sub a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.rip-pills { display: flex; gap: 10px; }
.rip-pill { min-width: 120px; padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,0.06); border: 1px solid var(--line-2); text-align: left; display: flex; flex-direction: column; gap: 2px; }
.rip-pill b { font-weight: 500; font-size: 16px; }
.rip-pill.gold b { color: var(--gold); }
.rip-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; text-transform: none; letter-spacing: 0; font-size: 11px; }
.rip-stats b { color: var(--ink); font-weight: 500; }

/* slide to rip */
.slide { position: relative; width: min(100%, 420px); height: 64px; border-radius: 999px; background: #141518; border: 1px solid var(--line-2); overflow: hidden; touch-action: none; user-select: none; cursor: grab; }
.slide:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.slide-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, rgba(245,197,66,0.35), rgba(245,197,66,0.08)); }
.slide-knob { position: absolute; left: 6px; top: 6px; width: 52px; height: 52px; border-radius: 50%; background: var(--gold); color: #1a1200; display: grid; place-items: center; font-size: 24px; font-weight: 600; box-shadow: 0 6px 20px rgba(245,197,66,0.4); transform: translateX(var(--x, 0px)); }
.slide.snapping .slide-knob { transition: transform 260ms var(--ease-out); }
.slide-label { position: absolute; inset: 0 0 0 70px; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 15px; pointer-events: none; }
.slide-label::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent); background-size: 50% 100%; background-repeat: no-repeat; animation: shimmer 2.2s linear infinite; mix-blend-mode: overlay; }
@keyframes shimmer { from { background-position: -100% 0; } to { background-position: 200% 0; } }
.rip-queue { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.rq { width: 28px; height: 44px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.25); background: #0c0d0f url("art/pack-tear.png") center / contain no-repeat; cursor: pointer; padding: 0; opacity: 0.9; }
.rq:hover { border-color: var(--gold); }

.rip-result { position: absolute; inset: auto 16px 16px; z-index: 7; margin: 0 auto; max-width: 520px; padding: 16px 18px; border-radius: 18px; background: rgba(12,10,14,0.88); border: 1px solid rgba(255,255,255,0.18); backdrop-filter: blur(12px); animation: sheetin 500ms var(--ease-spring); }
.rip-result[hidden] { display: none; }
@keyframes sheetin { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: none; } }
.rtag { display: inline-block; padding: 4px 9px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.25); font: 500 11px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.rtag.hit { background: var(--gold); color: #1a1200; border-color: var(--gold); }
.rip-result h3 { margin: 10px 0 2px; font: 500 22px/1.15 var(--sans); letter-spacing: -0.01em; }
.rip-result .rsub { margin: 0; font-size: 12px; color: var(--muted); }
.rlines { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; }
.rlines li { display: flex; align-items: baseline; gap: 10px; font-size: 13px; padding: 8px 0; border-top: 1px solid rgba(255,255,255,0.08); }
.rlines li span { color: var(--muted); flex: 1; }
.rlines li b { font-weight: 500; }
.rlines li.gold b { color: var(--gold); }
.rlines li a, .rlines .simtx { font: 400 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.rlines .simtx { text-decoration: none; opacity: 0.5; }
.rlines li em { font-size: 11px; color: var(--muted); }
.rsay { margin: 10px 0 0; font-size: 12px; color: var(--ink-2); font-style: italic; }
.rip-actions { display: flex; gap: 10px; margin-top: 12px; }
.rip-actions .btn, .rip-actions .ghost { height: 44px; display: inline-flex; }

/* ---------- phases ---------- */
#rip:not([data-phase="idle"]) .rip-sheet { opacity: 0; transform: translateY(12px); pointer-events: none; }
#rip[data-phase="ignite"] .rip-bg, #rip[data-phase="rise"] .rip-bg { background: #050507; }
#rip:not([data-phase="idle"]) .rip-spot { opacity: 0; }
#rip[data-phase="ignite"] .rip-pack-wrap { animation: ignite var(--t-ignite) cubic-bezier(0.6, 0, 0.9, 0.4) forwards; }
#rip[data-phase="ignite"] .rip-pack { animation: none; filter: brightness(3) saturate(1.4) drop-shadow(0 0 40px #fff) drop-shadow(0 0 90px #ffd9a0); }
@keyframes ignite { to { top: 78%; transform: translate(-50%, -50%) scale(0.42); } }
#rip[data-phase="rise"] .rip-bg, #rip[data-phase="float"] .rip-bg, #rip[data-phase="burst"] .rip-bg { background: radial-gradient(70% 60% at 50% 50%, #2a1f45, #0a0912 70%); }
#rip[data-phase="rise"] .rip-pack-wrap { top: 78%; transform: translate(-50%, -50%) scale(0.42); animation: rise var(--t-rise) var(--ease-out) forwards; }
#rip[data-phase="rise"] .rip-pack { animation: none; filter: brightness(1.6) drop-shadow(0 0 40px rgba(255,255,255,0.6)); transition: filter var(--t-rise); }
@keyframes rise { to { top: 46%; transform: translate(-50%, -50%) scale(1); } }
#rip[data-phase="rise"] .rip-spokes, #rip[data-phase="float"] .rip-spokes, #rip[data-phase="burst"] .rip-spokes { opacity: 1; animation: spin 14s linear infinite; }
#rip[data-phase="float"] .rip-spokes.two, #rip[data-phase="burst"] .rip-spokes.two { animation: spin 22s linear infinite reverse; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
#rip[data-phase="float"] .rip-pack-wrap, #rip[data-phase="burst"] .rip-pack-wrap { top: 46%; transform: translate(-50%, -50%) scale(1); }
#rip[data-phase="float"] .rip-pack { animation: yaw var(--t-float) ease-in-out infinite; filter: brightness(1.25) drop-shadow(0 0 30px rgba(255,255,255,0.55)) drop-shadow(0 40px 50px rgba(0,0,0,0.7)); }
@keyframes yaw { 0% { transform: rotateY(-18deg) rotateX(4deg); } 50% { transform: rotateY(18deg) rotateX(-4deg) translateY(-6px); } 100% { transform: rotateY(-18deg) rotateX(4deg); } }
#rip[data-phase="float"] .rip-flare.a, #rip[data-phase="burst"] .rip-flare.a { opacity: 1; animation: flarepulse 1.6s ease-in-out infinite; }
#rip[data-phase="float"] .rip-flare.b { opacity: 0.8; }
@keyframes flarepulse { 50% { transform: translate(-50%, -50%) scale(1.25); } }
#rip[data-phase="burst"] .rip-pack { animation: burst var(--t-burst) cubic-bezier(0.5, 0, 0.9, 0.3) forwards; }
@keyframes burst { 0% { transform: rotateY(-18deg); filter: brightness(1.3); } 60% { transform: rotateY(30deg) rotateZ(-14deg) scale(1.25); filter: brightness(2.2) drop-shadow(0 0 60px #fff); } 100% { transform: rotateY(36deg) rotateZ(-18deg) scale(1.5); filter: brightness(6) drop-shadow(0 0 120px #fff); opacity: 0; } }
#rip[data-phase="burst"] .rip-bloom { animation: bloom var(--t-burst) ease-in forwards; }
@keyframes bloom { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0); } 70% { opacity: 1; } 100% { opacity: 1; transform: translate(-50%, -50%) scale(260); } }
#rip[data-phase="shards"] .rip-bg, #rip[data-phase="settle"] .rip-bg, #rip[data-phase="done"] .rip-bg { background: radial-gradient(60% 50% at 50% 46%, var(--magenta-deep), var(--rip-red) 60%, #4a0824 100%); }
#rip[data-phase="shards"] .rip-bloom { opacity: 1; transform: translate(-50%, -50%) scale(260); animation: bloomfade var(--t-shards) linear forwards; }
@keyframes bloomfade { to { opacity: 0; } }
#rip[data-phase="shards"] .rip-pack-wrap, #rip[data-phase="settle"] .rip-pack-wrap, #rip[data-phase="done"] .rip-pack-wrap { opacity: 0; }
#rip[data-phase="shards"] .rip-card { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotateX(28deg) rotateY(-22deg) rotateZ(-8deg); transition: transform var(--t-shards) var(--ease-out), opacity 120ms; }
#rip[data-phase="settle"] .rip-card, #rip[data-phase="done"] .rip-card { opacity: 1; transform: translate(-50%, -50%) scale(1) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform var(--t-settle) var(--ease-spring); }
#rip[data-phase="done"] .rip-scene { pointer-events: none; }
#rip[data-phase="done"] .rip-card { pointer-events: auto; box-shadow: 0 60px 100px rgba(0,0,0,0.6), 0 0 120px rgba(255,120,180,0.5); transition: transform 200ms ease-out; }
#rip[data-phase="done"] .rip-flare.b { opacity: 0.5; top: 46%; transform: translate(-50%, -50%) scale(2.6); background: radial-gradient(circle, rgba(255,160,200,0.45), transparent 65%); }

@media (max-width: 760px) {
  .rip-pack-wrap { width: 56vw; top: 30%; }
  .rip-card { width: 70vw; top: 36%; }
  #rip[data-phase="done"] .rip-card { top: 34%; }
  .rip-result { max-height: 48vh; overflow: auto; inset: auto 10px 10px; }
  .rip-pill { min-width: 0; flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #rip *, #rip *::after { animation-duration: 0.01s !important; transition-duration: 0.01s !important; }
}
