/* Typography and colour are taken from nifewars.com: NW Display 800 for headings,
   Inter for body and navigation, Switzer for buttons. */
@font-face { font-family: "NW Display"; src: url("../assets/fonts/nw-display-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Inter Display"; src: url("../assets/fonts/inter-display-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../assets/fonts/inter-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../assets/fonts/inter-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../assets/fonts/inter-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../assets/fonts/inter-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Switzer"; src: url("../assets/fonts/switzer-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Switzer"; src: url("../assets/fonts/switzer-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --ink: #0a0a0d;
  --ink-soft: #171717;
  --body: #606063;
  --muted: #575757;
  --line: #e7e7ea;
  --panel: #f5f5f6;
  --pink: #ec1e79;
  --magenta: #ff00b2;
  --pink-grad: linear-gradient(180deg, #ff00b2 0%, #f170ff 100%);
  --blue-grad: linear-gradient(180deg, #00d4ff 0%, #0077ff 100%);
  --violet-grad: linear-gradient(180deg, #5235ef 0%, #8771ff 100%);
  --display: "NW Display", "Inter Display", Inter, sans-serif;
  --sans: Inter, system-ui, sans-serif;
  --btn: Switzer, Inter, sans-serif;
  --wrap: 1280px;
  --head: 72px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: #fff; color: var(--ink); font: 400 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; letter-spacing: -0.02em; line-height: 1; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(32px, 3.2vw, 44px); }
h2 { font-size: clamp(26px, 2.6vw, 34px); }
h3 { font-size: 20px; line-height: 1.1; }
p { margin: 0; }
:focus-visible { outline: 2px solid #5235ef; outline-offset: 3px; }
.lede { color: var(--body); max-width: 620px; }

/* Header */
.site-head { position: sticky; top: 0; z-index: 40; background: #fff; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; padding: 0 24px; height: var(--head); }
.logo img { height: 36px; width: auto; }
.site-nav { display: flex; gap: 6px; }
.site-nav a { font: 500 16px/1 var(--sans); color: var(--ink-soft); text-decoration: none; padding: 13px 20px; border-radius: 55px; white-space: nowrap; }
.site-nav a:hover { background: var(--panel); }
.site-nav a.on { background: #000; color: #fff; }
.head-actions { display: flex; gap: 12px; justify-content: flex-end; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border: 0; border-radius: 999px; font: 600 15px/1 var(--btn); letter-spacing: -0.3px; color: #fff; text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform .15s ease, filter .15s ease; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .4; cursor: not-allowed; transform: none; filter: none; box-shadow: none; }
.btn-pink { background: var(--pink-grad); box-shadow: 0 6px 20px rgba(240, 53, 215, .6); }
.btn-blue { background: var(--blue-grad); box-shadow: 0 6px 20px rgba(0, 155, 255, .45); }
.btn-line { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn-ghost { background: rgba(255, 255, 255, .1); color: #fff; }
.btn-ghost:hover { background: rgba(255, 255, 255, .16); }
.btn-big { height: 60px; padding: 0 44px; font-size: 20px; }
.btn .count { background: rgba(255, 255, 255, .28); border-radius: 99px; padding: 3px 8px; font-size: 13px; }
.link-btn { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: inherit; }

/* Layout helpers */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.page { padding-top: 28px; padding-bottom: 72px; }
.page-head { display: grid; gap: 12px; justify-items: start; margin-bottom: 28px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.center { justify-content: center; }
.foe-facts { font: 600 14px/1.4 var(--sans); color: var(--muted); }

.pills { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pill { border: 0; cursor: pointer; border-radius: 33px; padding: 9px 20px; font: 600 15px/1.3 var(--sans); letter-spacing: -0.02em; color: #101011; background: linear-gradient(180deg, #fff 0%, #eaeaea 100%); box-shadow: 0 3px 16px rgba(0, 0, 0, .12); }
.pill.on { color: #fff; background: var(--violet-grad); box-shadow: 0 3px 16px #5135f0; }
.pill[disabled] { opacity: .5; cursor: not-allowed; }
.pills.small { gap: 8px; }
.pills.small .pill { padding: 6px 14px; font-size: 13px; }

.bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--pink-grad); transition: width .35s ease; }
.bar.light { background: #e1e1e5; }
.curve { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; align-items: end; height: 56px; }
.curve div { background: #0a0a0d; border-radius: 4px 4px 0 0; min-height: 2px; }
.curve-x { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; font: 600 12px/1 var(--sans); color: var(--muted); text-align: center; }

/* Lobby */
.lobby { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; padding: 8px 24px 24px; height: calc(100vh - var(--head)); min-height: 640px; }
.stage { --cw: clamp(92px, min(12vw, 21vh), 200px); position: relative; isolation: isolate; overflow: hidden; min-width: 0; border-radius: 28px; background: #0a0a0d; color: #fff; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 22px; padding: 28px 32px 20px; }
.stage-bg { position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 10, 13, .5) 0%, rgba(10, 10, 13, .86) 62%, #0a0a0d 100%), url("../assets/brand/banner.png") 50% 30% / cover; }
.vs { display: flex; align-items: center; justify-content: center; gap: clamp(20px, 5vw, 88px); min-height: 0; }
.vs-side { display: grid; justify-items: center; gap: 18px; }
.vs-fan { display: flex; align-items: flex-end; }
.vs-fan .card { width: var(--cw); margin: 0 calc(var(--cw) * -.2); }
.vs-fan .card:first-child { transform: rotate(-9deg) translateY(6%); }
.vs-fan .card:nth-child(2) { z-index: 1; }
.vs-fan .card:nth-child(3) { transform: rotate(9deg) translateY(6%); }
.vs-fan .card:only-child, .vs-fan .card:first-child:nth-last-child(2) { transform: none; }
.vs-foe .card { width: calc(var(--cw) * 1.22); transform: rotate(3deg); box-shadow: 0 0 0 3px rgba(255, 255, 255, .9), 0 24px 60px rgba(0, 0, 0, .6); }
.vs-tag { text-align: center; display: grid; gap: 3px; }
.vs-tag b { font: 800 20px/1 var(--display); letter-spacing: -0.01em; }
.vs-tag span { font-size: 14px; color: rgba(255, 255, 255, .65); }
.vs-x { font: 800 clamp(40px, 5vw, 76px)/1 var(--display); letter-spacing: -0.03em; color: var(--magenta); text-shadow: 0 0 40px rgba(255, 0, 178, .55); }
.stage-info { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: end; }
.stage-info h1 { font-size: clamp(32px, 3.6vw, 56px); }
.stage-info p { color: rgba(255, 255, 255, .72); margin-top: 8px; }
.stage-go { display: grid; justify-items: center; gap: 10px; }
.stage-note { font-size: 14px; color: rgba(255, 255, 255, .7); max-width: 260px; text-align: center; }
.track { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 16px; }
.node { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: center; text-align: left; background: none; border: 0; border-radius: 14px; padding: 6px; color: #fff; cursor: pointer; }
.node:hover:not([disabled]) { background: rgba(255, 255, 255, .08); }
.node.on { background: rgba(255, 255, 255, .12); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .4); }
.node[disabled] { cursor: default; }
.node-art { position: relative; width: 44px; height: 44px; }
.node-art img { width: 100%; height: 100%; border-radius: 12px; object-fit: cover; object-position: 50% 14%; }
.node-art i { position: absolute; right: -5px; bottom: -5px; width: 20px; height: 20px; border-radius: 50%; background: var(--pink-grad); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 2px #0a0a0d; }
.node-art svg { width: 11px; height: 11px; }
.node.locked img { filter: grayscale(1) brightness(.5); }
.node-text { display: grid; min-width: 0; }
.node-text b { font: 600 13px/1.25 var(--sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-text small { font-size: 12px; color: rgba(255, 255, 255, .55); }
.node.locked .node-text b { color: rgba(255, 255, 255, .5); }

.lobby-side { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px; display: grid; gap: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.panel-head a { font: 600 14px/1 var(--sans); color: var(--pink); text-decoration: none; }
.panel-head a:hover { text-decoration: underline; }
.panel-note { font: 500 14px/1.4 var(--sans); color: var(--muted); }
.panel-bags { grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 18px; }
.panel-bags > div:last-child { display: grid; gap: 8px; justify-items: start; }
.record { grid-template-columns: repeat(3, 1fr); text-align: center; margin-top: auto; }
.record strong { display: block; font: 800 28px/1 var(--display); letter-spacing: -0.02em; }
.record span { font: 600 13px/1.6 var(--sans); color: var(--muted); }

/* Wallet, gate and rewards */
[hidden] { display: none !important; }
.fineprint { font-size: 12px; line-height: 1.45; color: var(--muted); padding: 0 6px; }
.kv { margin: 0; width: 100%; display: grid; gap: 6px; text-align: left; }
.kv div { display: flex; justify-content: space-between; gap: 16px; background: var(--panel); border-radius: 10px; padding: 10px 14px; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.ca { display: flex; align-items: center; gap: 12px; max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.ca code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, Consolas, monospace; }
.ca .link-btn { font-weight: 600; flex: none; }
.wallet-list { display: grid; gap: 10px; width: 100%; }
.form-error { color: #b4123f; font-weight: 600; font-size: 14px; }
.form-ok { color: #128a4c; font-weight: 600; font-size: 14px; }
.banner-note { background: #fff4f8; border: 1px solid #ffc2dc; color: #7a0f3c; border-radius: 12px; padding: 12px 16px; font-size: 15px; }
.rw-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.rw-grid .wide { grid-column: 1 / -1; }
.big-num { font: 800 34px/1 var(--display); letter-spacing: -0.02em; }
.big-num small { font: 600 14px/1 var(--sans); letter-spacing: 0; color: var(--muted); }
.record.flat { margin: 0; display: grid; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td, .table th { padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; }
.table tr:last-child td { border-bottom: 0; }
.table td:last-child, .table th:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Connect wall */
body.walled .site-head { display: none; }
body.walled { background: #0a0a0d; }
.wall { position: relative; isolation: isolate; overflow: hidden; min-height: 100vh; display: grid; place-items: center; padding: 24px; color: #fff; }
.wall::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse 60% 55% at 50% 46%, rgba(10, 10, 13, .25) 0%, rgba(10, 10, 13, .88) 100%); }
.wall-card { width: min(460px, 100%); display: grid; gap: 18px; justify-items: center; text-align: center; background: rgba(10, 10, 13, .74); border: 1px solid rgba(255, 255, 255, .14); border-radius: 28px; padding: 40px 32px 32px; }
.wall-logo { height: 44px; width: auto; }
.wall-card h1 { font-size: clamp(30px, 5vw, 38px); }
.wall-card .lede { color: rgba(255, 255, 255, .78); }
.wall-card .wallet-list .btn { width: 100%; }
.wall-card .btn-line { background: transparent; color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .55); }
.wall-card .ca { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); }
.wall-card .fineprint { color: rgba(255, 255, 255, .55); }
.wall-card .form-error { color: #ff7a9c; }

/* Card */
.card { --frame: linear-gradient(135deg, rgba(255,255,255,.55), rgba(255,255,255,.12)); position: relative; aspect-ratio: 5 / 7; container-type: inline-size; border-radius: 6.5% / 4.6%; overflow: hidden; background: #111; color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .22); user-select: none; isolation: isolate; }
.card-art { position: absolute; inset: 0; }
.card-art img { width: 100%; height: 100%; }
.card-art.contain img { padding: 12cqw 8cqw 46cqw; }
.card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.5cqw; background: var(--frame); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; z-index: 3; }
.card-plate { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 22cqw 6cqw 5cqw; background: linear-gradient(180deg, rgba(10,10,13,0) 0%, rgba(10,10,13,.88) 36%, rgba(10,10,13,.96) 100%); text-align: center; display: grid; gap: 1cqw; }
.card-name { font: 800 10cqw/1 var(--display); letter-spacing: -0.01em; text-transform: uppercase; }
.card-name.long { font-size: 8.2cqw; }
.card-sub { font: 600 5.2cqw/1.2 var(--sans); color: rgba(255, 255, 255, .7); }
.card-text { font: 500 5.1cqw/1.28 var(--sans); color: rgba(255, 255, 255, .92); margin-top: 2cqw; min-height: 13cqw; display: flex; flex-direction: column; justify-content: center; text-wrap: balance; }
.card-text b { font-weight: 700; color: #fff; }
.card-stats { display: flex; align-items: center; justify-content: space-between; margin-top: 2cqw; height: 16cqw; }
.badge { width: 16cqw; height: 16cqw; border-radius: 50%; display: grid; place-items: center; font: 800 9.4cqw/1 var(--display); font-variant-numeric: tabular-nums; }
.badge.atk { background: var(--pink-grad); }
.badge.hp { background: #fff; color: var(--ink); }
.badge.hp.hurt { color: #d92d4b; }
.badge.up { box-shadow: 0 0 0 1cqw #35d07f; }
.card-cost { position: absolute; top: 4.5cqw; left: 4.5cqw; z-index: 2; width: 17cqw; height: 17cqw; border-radius: 50%; display: grid; place-items: center; background: var(--blue-grad); font: 800 10cqw/1 var(--display); box-shadow: 0 1cqw 4cqw rgba(0, 0, 0, .35); }
.card-par { position: absolute; top: 5.5cqw; right: 5cqw; z-index: 2; font: 700 4.3cqw/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; background: rgba(10, 10, 13, .78); padding: 2cqw 3cqw; border-radius: 99px; }
.rarity { font: 700 4.3cqw/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .6); }
.rar-rare .rarity { color: #5cc8ff; }
.rar-epic .rarity { color: #b9a6ff; }
.rar-legendary .rarity { color: #ffc93c; }

.par-nickel { --frame: linear-gradient(135deg, #f6f6f8, #9aa0a8 30%, #ffffff 52%, #8b9098 78%, #e9eaec); }
.par-iron { --frame: linear-gradient(135deg, #6a7078, #1d1f23 32%, #8d939b 54%, #2a2c30 80%, #5c6168); }
.par-nife { --frame: linear-gradient(135deg, #00d4ff, #0077ff 34%, #ffd34d 56%, #00b2ff 82%, #7fe7ff); }
.par-gray { --frame: linear-gradient(135deg, #c5cdbf, #6f7a6c 32%, #e6ebe0 54%, #5d665b 80%, #aab3a4); }
.par-gold { --frame: linear-gradient(135deg, #fff1b0, #d9a520 32%, #fff7d1 54%, #b8860b 80%, #ffe27a); }
.par-adallium { --frame: linear-gradient(135deg, #ff00b2, #f170ff 32%, #ffd1f3 54%, #ff00b2 80%, #c56bff); }
.card:not(.par-base)::after { padding: 2.6cqw; }
.card:not(.par-base)::before { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.34) 46%, rgba(255,255,255,.06) 54%, transparent 68%); background-size: 260% 100%; background-position: 120% 0; mix-blend-mode: screen; transition: background-position .9s ease; }
.card:not(.par-base):hover::before { background-position: -40% 0; }

.card.is-unit .card-plate { padding-top: 16cqw; }
.card.is-unit .card-sub { display: none; }
.card.is-unit .card-text { min-height: 6cqw; margin-top: .5cqw; font-size: 5.6cqw; color: rgba(255, 255, 255, .78); }
.card.is-unit .card-cost, .card.is-unit .card-par, .card.is-unit .rarity { display: none; }
.card.waiting .card-art { filter: saturate(.35) brightness(.7); }
.card-flag { position: absolute; top: 5cqw; left: 50%; transform: translateX(-50%); z-index: 2; font: 700 5cqw/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; background: rgba(10, 10, 13, .8); padding: 2.4cqw 4cqw; border-radius: 99px; white-space: nowrap; }

.card-back { position: relative; aspect-ratio: 5 / 7; border-radius: 6.5% / 4.6%; background: #0a0a0d; display: grid; place-items: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .22), inset 0 0 0 2px rgba(255, 255, 255, .16); overflow: hidden; }
.card-back img { width: 74%; }

/* Collection */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; }
.tile { background: #f5f5f5; border: 0; border-radius: 22px; padding: 10px 10px 14px; text-align: center; cursor: pointer; display: grid; gap: 10px; transition: transform .18s ease, box-shadow .18s ease; }
.tile:hover { transform: translateY(-4px); box-shadow: 0 14px 34px rgba(0, 0, 0, .12); }
.tile .card { box-shadow: none; }
.tile-meta { font: 600 14px/1.3 var(--sans); color: var(--muted); }
.tile.missing .card { filter: grayscale(1) brightness(.6); opacity: .55; }

.modal { position: fixed; inset: 0; z-index: 80; background: rgba(10, 10, 13, .66); display: grid; place-items: center; padding: 24px; overflow: auto; }
.sheet { background: #fff; color: var(--ink); border-radius: 24px; width: min(880px, 100%); padding: 32px; position: relative; display: grid; grid-template-columns: 300px 1fr; gap: 36px; align-items: start; }
.sheet.narrow { grid-template-columns: 1fr; width: min(460px, 100%); text-align: center; justify-items: center; gap: 18px; padding: 44px 36px; }
.sheet.narrow h2 { font-size: 48px; }
.sheet .close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--panel); cursor: pointer; font-size: 20px; line-height: 1; }
.detail { display: grid; gap: 16px; align-content: start; }
.detail h2 { font-size: 40px; text-transform: uppercase; }
.detail .role { font-weight: 600; color: var(--muted); margin-top: -8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: 600 13px/1 var(--sans); background: var(--panel); border: 1px solid var(--line); padding: 8px 12px; border-radius: 99px; }
.detail dl { margin: 0; display: grid; gap: 10px; }
.detail dt { font-weight: 700; }
.detail dd { margin: 0; color: var(--body); }
.detail .lore { color: var(--body); border-top: 1px solid var(--line); padding-top: 16px; }
.copies { display: grid; gap: 6px; font-size: 15px; }
.copies div { display: flex; justify-content: space-between; background: var(--panel); border-radius: 8px; padding: 8px 12px; }
.copies span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 15px; text-align: center; padding: 18px 0; }

/* Deck builder */
.builder { display: grid; grid-template-columns: 1fr 340px; gap: 32px; align-items: start; }
.builder .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.pick { position: relative; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; display: grid; gap: 8px; }
.pick[disabled] { cursor: not-allowed; }
.pick.off .card { filter: grayscale(.9) brightness(.75); opacity: .55; }
.pick .card { transition: transform .15s ease; }
.pick:not([disabled]):hover .card { transform: translateY(-4px); }
.pick-meta { font: 600 13px/1.2 var(--sans); color: var(--muted); display: flex; justify-content: space-between; }
.pick-meta b { color: var(--pink); }
.deck-panel { position: sticky; top: calc(var(--head) + 12px); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 20px; display: grid; gap: 14px; }
.deck-name { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: 700 18px/1.2 var(--sans); background: #fff; color: var(--ink); }
.deck-count { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; color: var(--muted); }
.deck-count strong { font: 800 32px/1 var(--display); color: var(--ink); }
.deck-count strong.ok { color: #128a4c; }
.deck-list { display: grid; gap: 4px; max-height: 40vh; overflow: auto; }
.deck-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; background: #fff; border: 0; border-radius: 8px; padding: 6px 10px 6px 6px; cursor: pointer; text-align: left; font-size: 14px; }
.deck-row:hover { background: #ffe9f5; }
.deck-row i { width: 28px; height: 28px; border-radius: 50%; background: var(--blue-grad); color: #fff; display: grid; place-items: center; font: 800 15px/1 var(--display); font-style: normal; }
.deck-row b { font-weight: 600; }
.deck-row small { color: var(--muted); font-size: 13px; }
.deck-row span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Blind bags */
.bag-stage { display: grid; justify-items: center; align-content: center; gap: 32px; min-height: min(620px, calc(100vh - 250px)); padding: 44px 28px; border-radius: 28px; color: #fff; background: radial-gradient(ellipse 70% 60% at 50% 38%, #3a0f3c 0%, #14080f 55%, #0a0a0d 100%); }
.bag { width: 230px; aspect-ratio: 3 / 4; border-radius: 10px 10px 16px 16px; background: linear-gradient(100deg, #1d1d23 0%, #3b3b46 22%, #121216 48%, #32323b 74%, #17171b 100%); position: relative; display: grid; place-items: center; box-shadow: 0 30px 60px rgba(0, 0, 0, .5), 0 0 90px rgba(255, 0, 178, .35); }
.bag::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 11%; background: repeating-linear-gradient(90deg, rgba(255,255,255,.16) 0 3px, transparent 3px 7px); border-bottom: 1px solid rgba(255, 255, 255, .2); border-radius: 10px 10px 0 0; }
.bag img { width: 76%; }
.bag span { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, .7); font: 700 12px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; }
.bag.mini { width: 76px; border-radius: 5px 5px 8px 8px; box-shadow: 0 10px 22px rgba(0, 0, 0, .25); }
.bag.shake { animation: bagshake .5s ease; }
@keyframes bagshake { 20% { transform: rotate(-4deg); } 40% { transform: rotate(4deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }
.pulls { display: grid; grid-template-columns: repeat(5, minmax(0, 200px)); gap: 20px; justify-content: center; width: 100%; }
.pull { perspective: 1200px; background: none; border: 0; padding: 0; cursor: pointer; display: grid; gap: 10px; }
.flip { position: relative; aspect-ratio: 5 / 7; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
.flip > * { position: absolute; inset: 0; backface-visibility: hidden; }
.flip > .card { transform: rotateY(180deg); }
.pull.open .flip { transform: rotateY(180deg); }
.pull.open { cursor: default; }
.pull:not(.open):hover .flip { transform: translateY(-6px); }
.pull-note { font: 600 13px/1.2 var(--sans); color: rgba(255, 255, 255, .6); text-align: center; min-height: 16px; visibility: hidden; }
.pull.open .pull-note { visibility: visible; }
.pull-note b { color: #ff7ad9; }
.odds { max-width: 720px; margin: 28px 0 0; }
.odds summary { cursor: pointer; font: 600 15px/1 var(--sans); color: var(--muted); padding: 8px 0; }
.odds table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 12px 0; }
.odds th, .odds td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.odds th { font-weight: 700; }
.odds td:last-child, .odds th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* Rules */
.rules { max-width: 860px; display: grid; gap: 44px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; counter-reset: step; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; counter-increment: step; }
.step::before { content: counter(step); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #000; color: #fff; font: 800 18px/1 var(--display); margin-bottom: 14px; }
.step b { display: block; margin-bottom: 6px; font-size: 17px; }
.step p { color: var(--body); font-size: 15px; }
.rules section { display: grid; gap: 16px; }
.rules ul { margin: 0; padding-left: 20px; color: var(--body); display: grid; gap: 8px; }
.rules li b { color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 14px 28px; color: var(--body); }
.legend span { display: inline-flex; align-items: center; gap: 10px; }
.legend i { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 800 16px/1 var(--display); font-style: normal; color: #fff; }
.kw-table { display: grid; gap: 0; border-top: 1px solid var(--line); }
.kw-table div { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kw-table b { font-weight: 700; }
.kw-table span { color: var(--body); }

/* Battle arena */
body.in-battle .site-head { display: none; }
body.in-battle { background: #0a0a0d; }
.battle { --slot: clamp(84px, min(calc((100vh - 290px) / 3.8), 14vw), 176px); --hand: calc(var(--slot) * .92); --board: calc(var(--slot) * 4 + 42px); position: relative; isolation: isolate; overflow: hidden; height: 100vh; min-height: 620px; color: #fff; display: grid; grid-template-columns: minmax(180px, 250px) minmax(0, 1fr) minmax(180px, 250px); grid-template-rows: auto minmax(0, 1fr); gap: 0 20px; padding: 0 20px; }
.arena-bg { position: absolute; inset: -80px; z-index: -1; background: url("../assets/brand/banner.png") 50% 40% / cover; filter: blur(26px) saturate(1.25) brightness(.5); }
.battle::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(ellipse 60% 55% at 50% 46%, rgba(10, 10, 13, .25) 0%, rgba(10, 10, 13, .88) 100%); }
.b-top { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 60px; }
.b-logo img { height: 28px; width: auto; }
.b-top .btn { justify-self: end; height: 36px; padding: 0 16px; font-size: 14px; }
.b-turn { display: flex; align-items: baseline; gap: 12px; }
.b-turn b { font: 800 24px/1 var(--display); letter-spacing: -0.01em; }
.b-turn span { font: 600 14px/1 var(--sans); color: rgba(255, 255, 255, .6); }

.b-left { display: grid; align-content: center; min-height: 0; padding-bottom: 60px; }
.inspect { display: grid; gap: 14px; }
.inspect .card { width: min(100%, 30vh); margin: 0 auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .6); }
.inspect dl { margin: 0; display: grid; gap: 6px; font-size: 13px; line-height: 1.4; }
.inspect dt { font-weight: 700; display: inline; }
.inspect dd { display: inline; margin: 0; color: rgba(255, 255, 255, .7); }
.inspect-empty { text-align: center; font-size: 14px; color: rgba(255, 255, 255, .4); }

.b-center { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); justify-items: center; gap: 10px; min-height: 0; min-width: 0; }
.hud { width: var(--board); max-width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 5px 18px 5px 5px; border-radius: 999px; background: rgba(10, 10, 13, .6); border: 1px solid rgba(255, 255, 255, .12); }
.core { --pct: 100%; position: relative; width: 54px; height: 54px; border-radius: 50%; padding: 3px; background: conic-gradient(#ff00b2 var(--pct), rgba(255, 255, 255, .16) 0); }
.core img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 12%; filter: brightness(.42); }
.core strong { position: absolute; inset: 0; display: grid; place-items: center; font: 800 24px/1 var(--display); font-variant-numeric: tabular-nums; }
.core.struck { animation: struck .4s ease; }
@keyframes struck { 25% { transform: translateX(-6px) scale(1.15); filter: brightness(1.8); } 60% { transform: translateX(5px); } }
.hud-name { display: grid; min-width: 0; }
.hud-name b { font: 800 18px/1.1 var(--display); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-name span { font-size: 13px; color: rgba(255, 255, 255, .6); white-space: nowrap; }
.hud-right { display: flex; align-items: center; gap: 18px; }
.hud-nife { display: flex; align-items: center; gap: 10px; }
.hud-nife strong { font: 800 22px/1 var(--display); min-width: 1ch; text-align: right; font-variant-numeric: tabular-nums; }
.pips { display: flex; gap: 4px; }
.pips i { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, .16); }
.pips i.full { background: var(--blue-grad); box-shadow: 0 0 8px rgba(0, 170, 255, .7); }
.pips i.extra { background: #ffd34d; box-shadow: 0 0 8px rgba(255, 211, 77, .7); }
.backs { display: flex; padding-left: 8px; }
.backs i { width: 17px; height: 24px; margin-left: -8px; border-radius: 3px; background: #0a0a0d; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .5); }

.b-board { display: grid; gap: 6px; justify-content: center; }
.b-row, .b-mid { display: grid; grid-template-columns: repeat(4, var(--slot)); gap: 14px; justify-content: center; }
.slot { aspect-ratio: 5 / 7; border-radius: 6.5% / 4.6%; background: rgba(255, 255, 255, .04); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .14); position: relative; display: grid; place-items: center; }
.slot > span { font: 800 26px/1 var(--display); color: rgba(255, 255, 255, .14); }
.slot .card { position: absolute; inset: 0; box-shadow: 0 10px 26px rgba(0, 0, 0, .6); }
.slot.target { box-shadow: inset 0 0 0 2px var(--magenta), 0 0 0 4px rgba(255, 0, 178, .25), 0 0 30px rgba(255, 0, 178, .35); cursor: pointer; }
.slot.target:hover { background: rgba(255, 0, 178, .16); }
.slot.target .card { opacity: .82; }
.b-mid { height: 30px; align-items: center; position: relative; }
.b-mid::before { content: ""; position: absolute; left: -40px; right: -40px; top: 50%; height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 0, 178, .8) 25%, rgba(0, 180, 255, .8) 75%, transparent); }
.clash { position: relative; display: flex; justify-content: center; gap: 8px; font: 700 13px/1 var(--sans); font-variant-numeric: tabular-nums; }
.clash span { display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border-radius: 99px; background: #23232b; color: rgba(255, 255, 255, .8); }
.clash .mine { background: #5c0f47; color: #ff9fe1; }
.clash svg { width: 9px; height: 9px; fill: currentColor; }

.b-right { display: flex; flex-direction: column; justify-content: center; gap: 12px; min-height: 0; padding-bottom: 60px; }
.end-turn { height: 68px; border: 0; border-radius: 999px; cursor: pointer; font: 800 24px/1 var(--display); letter-spacing: -0.01em; color: #fff; background: var(--pink-grad); box-shadow: 0 8px 34px rgba(240, 53, 215, .6); width: 100%; transition: transform .15s ease, filter .15s ease; }
.end-turn:hover:not([disabled]) { transform: scale(1.03); filter: brightness(1.08); }
.end-turn[disabled] { background: rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .45); box-shadow: none; cursor: default; }
.hint { min-height: 40px; text-align: center; font-size: 13px; line-height: 1.45; color: rgba(255, 255, 255, .7); }
.log { flex: 0 1 34vh; min-height: 0; overflow: auto; background: rgba(10, 10, 13, .6); border: 1px solid rgba(255, 255, 255, .1); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column-reverse; gap: 6px; font-size: 13px; line-height: 1.4; color: rgba(255, 255, 255, .62); }
.log p.turn { color: #fff; font-weight: 600; margin-top: 6px; }

.b-hand { align-self: end; display: flex; justify-content: center; align-items: flex-start; width: 100%; height: calc(var(--hand) * 1.1); }
.b-hand .card { --i: 0; width: var(--hand); flex: none; margin: 0 -9px; transform-origin: 50% 100%; transform: rotate(calc(var(--i) * 2.4deg)) translateY(calc(var(--i) * var(--i) * 3px)); transition: transform .16s ease, filter .16s ease; filter: brightness(.68) saturate(.7); cursor: default; box-shadow: 0 -6px 30px rgba(0, 0, 0, .55); }
.b-hand .card.can { filter: none; cursor: grab; }
.b-hand .card:hover { transform: translateY(-21%) scale(1.12); z-index: 5; }
.b-hand .card.sel { transform: translateY(-24%) scale(1.12); z-index: 6; box-shadow: 0 0 0 3px var(--magenta), 0 14px 40px rgba(255, 0, 178, .5); }
.b-hand .card.ghosted { opacity: .25; }
.drag-ghost { position: fixed; z-index: 90; pointer-events: none; width: var(--w); transform: translate(-50%, -60%) rotate(3deg); }
.hand-empty { color: rgba(255, 255, 255, .45); font-size: 14px; align-self: center; }

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
.floater { position: absolute; font: 800 38px/1 var(--display); color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .8), 0 0 2px #000; transform: translate(-50%, -50%); animation: floatup .8s ease-out forwards; }
.floater.dmg { color: #ff4d6d; }
.floater.heal { color: #4ade80; }
.floater.buff { color: #ffd34d; font-size: 24px; }
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 18% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -150%) scale(1); } }
.toast { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); font: 800 clamp(40px, 7vw, 88px)/1 var(--display); letter-spacing: -0.02em; color: #fff; text-shadow: 0 6px 40px rgba(0, 0, 0, .9), 0 0 60px rgba(255, 0, 178, .6); pointer-events: none; z-index: 60; animation: toast 1s ease forwards; white-space: nowrap; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -40%) scale(.9); } 20%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1.04); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (min-width: 1101px) {
  body.in-battle { overflow: hidden; }
}

@media (max-width: 1100px) {
  .lobby { grid-template-columns: 1fr; height: auto; }
  .stage { min-height: 560px; }
  .lobby-side { overflow: visible; }
  .record { margin-top: 0; }
  .track { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .battle { --slot: clamp(64px, min(14vh, 21vw), 150px); --hand: clamp(70px, min(13vh, 19vw), 130px); display: flex; flex-direction: column; height: auto; min-height: 100vh; gap: 10px; padding: 0 12px 12px; }
  .b-left, .log { display: none; }
  .b-center { display: contents; }
  .b-top { order: 0; height: 52px; }
  #r-opp { order: 1; }
  .b-board { order: 2; padding: 4px 0; }
  #r-me { order: 3; }
  .b-right { order: 4; padding: 0; }
  .b-hand { order: 5; height: calc(var(--hand) * 1.4 + 24px); align-items: flex-end; }
  #r-opp, #r-me { display: flex; justify-content: center; }
  .hud { width: 100%; }
  .b-row, .b-mid { gap: 8px; }
  .b-hand .card { margin: 0 -12px; }
  .b-hand .card:hover, .b-hand .card.sel { transform: translateY(-10%) scale(1.08); }
  #r-status { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; }
  .end-turn { order: 2; width: auto; height: 52px; padding: 0 28px; font-size: 20px; }
  .hint { text-align: left; min-height: 0; }
}
@media (max-width: 900px) {
  .site-head { grid-template-columns: 1fr auto; height: auto; padding: 10px 16px 6px; row-gap: 4px; position: static; }
  .site-nav { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; margin: 0 -16px; padding: 0 12px; }
  .site-nav a { padding: 10px 14px; font-size: 15px; }
  .wrap { padding: 0 16px; }
  .lobby { padding: 8px 12px 20px; }
  .stage { padding: 20px 16px 14px; border-radius: 22px; }
  .stage-info { grid-template-columns: 1fr; }
  .stage-go { justify-items: start; }
  .steps, .builder, .rw-grid { grid-template-columns: 1fr; }
  .sheet { grid-template-columns: 1fr; }
  .sheet > .card { max-width: 240px; margin: 0 auto; }
  .deck-panel { position: static; }
  .pulls { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .bag-stage { padding: 28px 14px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
}
@media (max-width: 560px) {
  .track { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { --cw: 19vw; min-height: 0; }
  .vs { gap: 10px; padding: 8px 0 4px; }
  .vs-x { font-size: 26px; }
  .vs-tag b { font-size: 16px; }
  .pips { display: none; }
  .hud-right { gap: 10px; }
  .kw-table div { grid-template-columns: 1fr; gap: 2px; }
}
