:root {
  --bg: #070a14;
  --panel: #0c111e;
  --panel-2: #111829;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #e8ecf6;
  --muted: #7d879c;
  --accent: #4d8dff;
  --r: 14px;
  --c-0: #9aa4b8; --c-1: #3fd28b; --c-2: #3d8bff; --c-3: #a463ff; --c-4: #ffb23d; --c-5: #ff4d7a;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: 0.02em; }
.caps { text-transform: uppercase; letter-spacing: 0.18em; font-size: 11px; color: var(--muted); }

.backdrop { position: fixed; inset: 0; z-index: -1; background: radial-gradient(1200px 600px at 70% -10%, rgba(77, 141, 255, 0.12), transparent 60%), var(--bg); }
.backdrop::after { content: ""; position: absolute; inset: 0; background: var(--bg-img, none) center / cover no-repeat; opacity: 0.22; mask-image: linear-gradient(to bottom, #000 0%, transparent 75%); transition: opacity 0.6s; }

.top { display: flex; align-items: center; gap: 28px; padding: 16px 28px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(7, 10, 20, 0.8); backdrop-filter: blur(12px); z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.2em; }
.brand img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.brand em { font-style: normal; font-weight: 400; color: var(--muted); letter-spacing: 0.1em; }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-size: 14px; transition: color 0.2s, background 0.2s; }
.top nav a:hover { color: var(--text); }
.top nav a.on { color: var(--text); background: var(--panel-2); }
.wallet { margin-left: auto; display: flex; gap: 8px; align-items: center; font-size: 13px; }

.btn { border: 1px solid var(--line-2); background: var(--panel-2); padding: 10px 18px; border-radius: 999px; font-size: 14px; transition: border-color 0.2s, transform 0.1s, background 0.2s; }
.btn:hover { border-color: rgba(255, 255, 255, 0.3); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #6aa0ff; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(255, 77, 122, 0.5); color: #ff8aa6; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.pill { padding: 6px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }

main { padding: 32px 28px 80px; max-width: 1280px; margin: 0 auto; }
.head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.head h1 { font-size: 30px; }
.head p { margin: 6px 0 0; color: var(--muted); max-width: 560px; line-height: 1.5; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 8px; }

/* ---------------------------------------------------------------- card */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 26px; }
.card-wrap { perspective: 900px; }
.card {
  --rc: var(--c-0);
  --mx: 50%; --my: 50%; --rx: 0deg; --ry: 0deg; --glare: 0;
  position: relative; aspect-ratio: 5 / 7; border-radius: 16px; cursor: pointer;
  transform: rotateX(var(--rx)) rotateY(var(--ry)); transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(.2,.8,.2,1), box-shadow 0.4s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.card.live { transition: transform 0.08s linear, box-shadow 0.3s; }
.card:hover { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--rc), 0 0 40px -8px var(--rc); }
.card .face { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; backface-visibility: hidden; background: linear-gradient(180deg, #0f1526, #0a0e1a); border: 1px solid color-mix(in srgb, var(--rc) 55%, transparent); }
.card .back { transform: rotateY(180deg); }
.card.flipped { transform: rotateY(calc(180deg + var(--ry))) rotateX(var(--rx)); }
.card .art { position: absolute; left: 0; right: 0; top: 0; height: 64%; background: radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--rc) 24%, transparent), transparent 62%); }
.card .art img { position: absolute; inset: 8% 10% 0; width: 80%; height: 92%; object-fit: contain; transform: translateZ(30px); filter: drop-shadow(0 8px 18px rgba(0,0,0,.6)); }
.card .art .glyph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; color: var(--rc); opacity: 0.8; }
.card .meta { position: absolute; left: 14px; right: 14px; bottom: 12px; }
.card .rar { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--rc); }
.card .name { font-size: 16px; font-weight: 600; margin: 3px 0 4px; }
.card .txt { font-size: 12px; color: var(--muted); line-height: 1.35; min-height: 32px; }
.card .row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 11px; color: var(--muted); }
.card .stats { display: flex; gap: 6px; }
.card .stats b { display: inline-flex; gap: 3px; align-items: center; color: var(--text); font-weight: 600; }
.card .stats i { font-style: normal; color: var(--muted); font-size: 9px; }
.card .serial { position: absolute; top: 10px; right: 12px; font-size: 10px; color: var(--muted); letter-spacing: 0.1em; }
.card .kind { position: absolute; top: 10px; left: 12px; font-size: 10px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
/* foil: rarity >= rare gets holo light, mythic gets prism */
.card .foil, .card .glare { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; mix-blend-mode: color-dodge; }
.card .glare { background: radial-gradient(circle at var(--mx) var(--my), rgba(255,255,255,.35), transparent 45%); opacity: var(--glare); mix-blend-mode: overlay; }
.card[data-r="2"] .foil, .card[data-r="3"] .foil { opacity: calc(var(--glare) * 0.5); background: linear-gradient(115deg, transparent 30%, color-mix(in srgb, var(--rc) 70%, #fff) 48%, transparent 66%) calc(var(--mx) * 1.6 - 30%) 0 / 200% 100%; }
.card[data-r="4"] .foil, .card[data-r="5"] .foil, .card.shiny .foil {
  opacity: calc(0.15 + var(--glare) * 0.55);
  background: repeating-linear-gradient(115deg, #ff4d7a 0%, #ffb23d 8%, #3fd28b 16%, #3d8bff 24%, #a463ff 32%, #ff4d7a 40%) calc(var(--mx) * 2) calc(var(--my) * 2) / 300% 300%;
  -webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, transparent 70%);
          mask-image: radial-gradient(circle at var(--mx) var(--my), #000 0%, transparent 70%);
}
.card .back { display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--rc) 18%, transparent), transparent 70%), #0a0e1a; }
.card .back .b-in { width: 82%; font-size: 12px; color: var(--muted); }
.card .back .b-in div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.card .back .b-in div b { color: var(--text); font-weight: 500; }
.card .back .sig { width: 64px; height: 64px; margin: 0 auto 16px; display: block; opacity: 0.9; border-radius: 12px; }

.card.sm { width: 150px; }
.card.lg { width: min(360px, 80vw); }
.card.lg .name { font-size: 22px; }
.card.lg .txt { font-size: 14px; }
.card.lg .meta { left: 20px; right: 20px; bottom: 18px; }

/* ---------------------------------------------------------------- forge */
.forge { display: grid; grid-template-columns: 1fr 420px; gap: 28px; align-items: start; }
.wheel-wrap { position: relative; aspect-ratio: 1; max-width: 560px; margin: 0 auto; width: 100%; }
.wheel-wrap canvas { width: 100%; height: 100%; display: block; }
.wheel-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.wheel-center .big { font-size: 34px; font-weight: 700; letter-spacing: 0.04em; }
.wheel-center .sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 12px 0 18px; }
.asset { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 12px; text-align: left; transition: border-color 0.2s; }
.asset.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.asset b { display: block; font-size: 14px; }
.asset span { font-size: 11px; color: var(--muted); }
.field { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-2); border-radius: 12px; padding: 4px 4px 4px 14px; background: var(--bg); }
.field input { flex: 1; background: none; border: 0; outline: 0; color: var(--text); font-size: 20px; padding: 10px 0; min-width: 0; }
.field .btn { padding: 8px 12px; font-size: 12px; }
.odds { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 18px; }
.odds td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.odds td:last-child, .odds td:nth-child(2) { text-align: right; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.note { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 14px; }
.reveal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(4, 6, 12, 0.82); backdrop-filter: blur(6px); animation: fade 0.3s; }
.reveal .stack { display: grid; justify-items: center; gap: 22px; }
.reveal .card { animation: drop 0.9s cubic-bezier(.2,1.4,.3,1); }
.burst { position: absolute; width: 900px; height: 900px; border-radius: 50%; background: conic-gradient(from 0deg, transparent, var(--rc), transparent 20%, var(--rc) 30%, transparent 40%, var(--rc) 55%, transparent 65%, var(--rc) 80%, transparent); opacity: 0.18; animation: spin 14s linear infinite; mask-image: radial-gradient(circle, #000 10%, transparent 60%); pointer-events: none; }
@keyframes drop { from { transform: translateY(-40px) scale(0.6) rotateY(180deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }

/* ---------------------------------------------------------------- inspect modal */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(4, 6, 12, 0.78); backdrop-filter: blur(8px); animation: fade 0.25s; padding: 24px; }
.inspect { display: grid; grid-template-columns: auto 380px; gap: 36px; align-items: center; max-width: 1000px; width: 100%; }
.inspect .left { display: grid; justify-items: center; gap: 16px; position: relative; }
.holo-stage { position: relative; height: 230px; border-radius: var(--r); overflow: hidden; background: radial-gradient(circle at 50% 100%, rgba(77, 141, 255, 0.18), transparent 70%); border: 1px solid var(--line); }
.holo-stage canvas { width: 100%; height: 100%; display: block; }
.holo-stage .hint { position: absolute; bottom: 8px; left: 12px; font-size: 11px; color: var(--muted); }
.bars { display: grid; gap: 10px; margin: 18px 0; }
.bar { display: grid; grid-template-columns: 96px 1fr 24px; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.bar .t { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.bar .t i { display: block; height: 100%; background: var(--rc, var(--accent)); border-radius: 3px; width: 0; transition: width 0.8s cubic-bezier(.2,.8,.2,1); }
.bar b { color: var(--text); text-align: right; }
.kv { font-size: 13px; }
.kv div { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.kv b { color: var(--text); font-weight: 500; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal[hidden] { display: none; }
.x { position: absolute; top: 18px; right: 22px; background: none; border: 0; font-size: 26px; color: var(--muted); }

/* ---------------------------------------------------------------- play */
.arena { position: relative; height: 560px; border-radius: 20px; overflow: hidden; border: 1px solid var(--line); background: radial-gradient(800px 400px at 50% 110%, rgba(77, 141, 255, 0.16), transparent 70%), linear-gradient(#0a0f1d, #070a14); }
.arena canvas.fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.guardian { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); text-align: center; width: 320px; }
.guardian .hp { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.guardian .hp i { display: block; height: 100%; background: linear-gradient(90deg, #ff4d7a, #ffb23d); transition: width 0.6s; }
.guardian .intent { font-size: 12px; color: var(--muted); margin-top: 6px; }
.guardian .gem { width: 110px; height: 110px; margin: 0 auto 8px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #ff9ab3, #ff4d7a 40%, #3a0b1f 75%); box-shadow: 0 0 60px rgba(255, 77, 122, 0.45); animation: breathe 3.2s ease-in-out infinite; }
.guardian.hit .gem { animation: shake 0.4s; }
@keyframes breathe { 50% { transform: scale(1.05); box-shadow: 0 0 90px rgba(255, 77, 122, 0.6); } }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
.pad { position: absolute; left: 50%; top: 300px; transform: translateX(-50%); width: 220px; height: 60px; border-radius: 50%; border: 1px solid rgba(77, 141, 255, 0.4); box-shadow: 0 0 40px rgba(77, 141, 255, 0.25) inset; }
.res { position: absolute; left: 22px; top: 22px; display: grid; gap: 6px; font-size: 12px; }
.res div { display: flex; gap: 10px; color: var(--muted); }
.res b { color: var(--text); min-width: 18px; }
.log { position: absolute; right: 22px; top: 22px; width: 220px; font-size: 12px; color: var(--muted); display: grid; gap: 4px; text-align: right; }
.hand { position: absolute; bottom: -38px; left: 0; right: 0; display: flex; justify-content: center; gap: 0; }
.hand .card-wrap { margin: 0 -14px; transition: transform 0.25s; }
.hand .card-wrap:hover { transform: translateY(-46px) scale(1.06); z-index: 2; }
.hand .card-wrap.used { opacity: 0; transform: translateY(-260px) scale(0.5); pointer-events: none; transition: transform 0.45s, opacity 0.45s; }
.endturn { position: absolute; right: 22px; bottom: 150px; }
.floater { position: absolute; font-weight: 800; font-size: 22px; pointer-events: none; animation: float 1.2s ease-out forwards; text-shadow: 0 0 12px currentColor; }
@keyframes float { from { transform: translate(-50%, 0); opacity: 1; } to { transform: translate(-50%, -70px); opacity: 0; } }
.holo-pop { position: absolute; left: 50%; top: 110px; width: 260px; height: 230px; transform: translateX(-50%); pointer-events: none; }

/* ---------------------------------------------------------------- misc */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120px); background: var(--panel-2); border: 1px solid var(--line-2); padding: 12px 18px; border-radius: 999px; font-size: 14px; transition: transform 0.3s; z-index: 50; }
.toast.on { transform: translateX(-50%); }
.feed { display: flex; gap: 8px; overflow: hidden; margin-bottom: 24px; mask-image: linear-gradient(90deg, #000 80%, transparent); }
.feed span { white-space: nowrap; font-size: 12px; }
.fees-table { width: 100%; border-collapse: collapse; }
.fees-table td, .fees-table th { text-align: left; padding: 14px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.fees-table th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.two p, .rules p { color: var(--muted); line-height: 1.6; }
@media (max-width: 900px) {
  .forge, .inspect, .two { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; gap: 12px; }
  .arena { height: 520px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
