:root {
  --bg: #050508;
  --ink: #e9ffe4;
  --dim: #8d9a8a;
  --lime: #7cff6b;
  --lime-2: #c6ff4d;
  --lav: #b9a3ff;
  --coral: #ff6f61;
  --panel: #0c0d12;
  --line: rgba(124, 255, 107, .16);
  --sl: max(12px, env(safe-area-inset-left));
  --sr: max(12px, env(safe-area-inset-right));
  --st: max(8px, env(safe-area-inset-top));
  --sb: max(6px, env(safe-area-inset-bottom));
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.35 ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: inherit; }

#app { position: fixed; inset: 0; overflow: hidden; display: grid;
  grid-template: "top" auto "stage" minmax(0, 1fr) "controls" auto "foot" auto / 100%;
  padding: var(--st) var(--sr) var(--sb) var(--sl);
  background: radial-gradient(120% 70% at 50% 38%, rgba(124, 255, 107, .07), transparent 60%), var(--bg); }

/* Top bar */
.top { grid-area: top; display: flex; align-items: center; gap: 8px; min-height: 48px; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; padding: 4px 2px; border-radius: 8px; }
.logo { width: 21px; height: 18px; fill: var(--lime); display: block; }
.word { font-weight: 700; font-size: 19px; letter-spacing: -.02em; }
.spacer { flex: 1; }
.holder { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 6px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: #120c22; background: var(--lav); }
.holder svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.tally { display: inline-flex; align-items: center; gap: 5px; color: var(--dim); font-size: 13px; padding: 0 4px; }
.tally svg { width: 16px; height: 16px; fill: var(--coral); }
.tally b { color: var(--ink); font-weight: 600; min-width: 1ch; }
.icon { width: 44px; height: 44px; display: inline-grid; place-items: center; padding: 0; border-radius: 14px; position: relative;
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.icon svg { width: 21px; height: 21px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon:hover { border-color: rgba(124, 255, 107, .45); }
.icon.small { width: 38px; height: 38px; border-radius: 12px; }
.icon.small svg { width: 17px; height: 17px; }
.dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); }
.dot.holder-dot { background: var(--lav); }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

/* Stage and cards */
.stage { grid-area: stage; position: relative; container-type: size; min-height: 0; isolation: isolate; z-index: 0; }
.deck { position: absolute; inset: 0; display: grid; place-items: center; }
.status { position: absolute; inset: auto 0 45% 0; margin: 0; text-align: center; color: var(--dim); font-size: 14px; pointer-events: none; }
.card { --w: min(100cqw, calc(100cqh - 86px), 460px);
  position: absolute; width: var(--w); border-radius: 22px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  background: linear-gradient(180deg, #111219, #0a0b10); border: 1px solid rgba(124, 255, 107, .22);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .04);
  will-change: transform; transform-origin: 50% 90%; cursor: grab; }
.card.dragging { cursor: grabbing; }
.card:not(.top-card) { pointer-events: none; }
.card.minted { border-color: rgba(185, 163, 255, .55); }
.card.boosted { border-color: rgba(255, 176, 32, .7); box-shadow: 0 0 0 1px rgba(255, 176, 32, .25), 0 18px 50px rgba(0, 0, 0, .55); }
.art { position: relative; aspect-ratio: 1; background:
  radial-gradient(70% 70% at 50% 45%, rgba(124, 255, 107, .10), transparent 70%),
  repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 2%),
  repeating-linear-gradient(90deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 2%), #07080c; }
.art img { position: absolute; inset: 4%; width: 92%; height: 92%; image-rendering: pixelated; -webkit-user-drag: none; pointer-events: none; }
.pills { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.pill { padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.pill.m { background: var(--lav); color: #120c22; }
.pill.b { background: #ffb020; color: #1f1400; }
.pill.r { background: rgba(124, 255, 107, .14); color: var(--lime); border: 1px solid rgba(124, 255, 107, .35); }
.info { height: 86px; padding: 10px 14px 12px; display: flex; flex-direction: column; justify-content: center; gap: 6px; border-top: 1px solid rgba(124, 255, 107, .1); }
.title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.num { color: var(--lime); font-weight: 700; font-size: 17px; }
.name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.traits { display: flex; gap: 6px; overflow: hidden; flex-wrap: nowrap; }
.traits span { flex: none; padding: 3px 8px; border-radius: 8px; font-size: 12px; color: #c9d6c5; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .06); white-space: nowrap; }
.traits span:first-child { color: var(--ink); border-color: rgba(124, 255, 107, .3); }
.stamp { position: absolute; top: 22px; padding: 6px 12px; border: 3px solid; border-radius: 10px; font-style: normal; font-weight: 800; font-size: 26px;
  letter-spacing: .08em; opacity: 0; pointer-events: none; background: rgba(5, 5, 8, .55); }
.stamp.love { left: 18px; color: var(--lime); border-color: var(--lime); transform: rotate(-12deg); }
.stamp.pass { right: 18px; color: var(--coral); border-color: var(--coral); transform: rotate(12deg); }
.glow { position: absolute; inset: 0; pointer-events: none; opacity: 0; border-radius: inherit; }
.glow.love { box-shadow: inset 0 0 0 3px var(--lime), inset 0 0 60px rgba(124, 255, 107, .35); }
.glow.pass { box-shadow: inset 0 0 0 3px var(--coral), inset 0 0 60px rgba(255, 111, 97, .3); }

/* Controls */
.controls { grid-area: controls; position: relative; display: flex; justify-content: center; align-items: center; gap: 28px; padding: 10px 0 6px; }
.act { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; padding: 0;
  background: var(--panel); border: 2px solid; -webkit-tap-highlight-color: transparent; transition: transform .12s, background .2s; }
.act svg { width: 30px; height: 30px; }
.act.pass { border-color: rgba(255, 111, 97, .6); }
.act.pass svg { fill: none; stroke: var(--coral); stroke-width: 2.6; stroke-linecap: round; }
.act.love { width: 78px; height: 78px; border-color: var(--lime); background: rgba(124, 255, 107, .08); }
.act.love svg { width: 34px; height: 34px; fill: var(--lime); }
.act:active { transform: scale(.92); }
.act.hit { animation: hit .35s ease-out; }
@keyframes hit { 40% { transform: scale(1.12); } }
.toast { position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, 6px); margin: 0 0 4px; padding: 5px 11px; border-radius: 999px; white-space: nowrap;
  font-size: 13px; background: #12131a; border: 1px solid var(--line); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: var(--lime); }
.toast.warn b { color: var(--coral); }

.foot { grid-area: foot; text-align: center; font-size: 12px; color: var(--dim); padding: 2px 0 2px; }
.foot a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--lime); text-underline-offset: 3px; text-decoration-thickness: 2px; }

/* Sheets */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .6); }
.sheet { position: fixed; z-index: 50; left: var(--sl); right: var(--sr); bottom: var(--sb); max-height: calc(100dvh - var(--st) - var(--sb) - 8px);
  display: flex; flex-direction: column; border-radius: 20px; background: #0a0b0f; border: 1px solid var(--line); box-shadow: 0 -10px 50px rgba(0, 0, 0, .7); }
#topSheet { top: calc(var(--st) + 8px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 16px; }
.sheet h2 { margin: 0; font-size: 14px; letter-spacing: .12em; text-transform: uppercase; color: var(--lime); }
.sheet h3 { margin: 16px 0 4px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #ffb020; }
.sheet-body { overflow: auto; overscroll-behavior: contain; padding: 0 16px 16px; }
.lead { margin: 0 0 12px; font-size: 14px; color: #c9d6c5; }
.tiny { font-size: 12px; color: var(--dim); margin: 8px 0 0; }
.tiny.center { text-align: center; padding: 30px 0; }
.err { color: var(--coral); min-height: 1em; }
.wallets { display: grid; gap: 8px; }
.wallet-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border-radius: 14px; border: 1px solid var(--line);
  background: #0f1016; cursor: pointer; text-align: left; font-size: 15px; }
.wallet-row:hover { border-color: rgba(124, 255, 107, .45); }
.wallet-row img, .wallet-row .wc { width: 30px; height: 30px; border-radius: 8px; flex: none; display: grid; place-items: center; background: #151721; }
.wallet-row .wc svg { width: 18px; height: 18px; fill: none; stroke: var(--lime); stroke-width: 2; stroke-linecap: round; }
.wallet-row span { flex: 1; }
.wallet-row small { color: var(--dim); font-size: 12px; }
.wallet-row[aria-busy="true"] { opacity: .6; pointer-events: none; }
.who { display: flex; align-items: center; gap: 10px; margin: 0; }
.addr { font-size: 16px; font-weight: 600; }
.chip { min-height: 40px; margin-top: 16px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #0f1016; cursor: pointer; font-size: 13px; }
.mine { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-top: 10px; }
.mine button { position: relative; padding: 0 0 6px; border-radius: 12px; border: 1px solid var(--line); background: #0f1016; cursor: pointer; font-size: 12px; }
.mine button img { width: 100%; aspect-ratio: 1; display: block; image-rendering: pixelated; }
.mine button[aria-pressed="true"] { border-color: #ffb020; box-shadow: 0 0 0 1px #ffb020; }
.mine button:disabled { cursor: default; opacity: .45; }
.mine button[aria-pressed="true"]:disabled { opacity: 1; }
.top-list { list-style: none; margin: 0; padding: 0 10px 12px 12px; overflow: auto; overscroll-behavior: contain; flex: 1; }
.top-list li a { display: grid; grid-template-columns: 30px 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 6px; border-radius: 12px; text-decoration: none; }
.top-list li a:hover { background: rgba(124, 255, 107, .05); }
.top-list .rk { color: var(--dim); font-size: 13px; text-align: right; }
.top-list li:nth-child(-n+3) .rk { color: var(--lime); font-weight: 700; }
.top-list img { width: 52px; height: 52px; border-radius: 10px; background: #07080c; image-rendering: pixelated; }
.top-list .nm { min-width: 0; }
.top-list .nm b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list .nm small { color: var(--dim); font-size: 12px; }
.top-list .sc { text-align: right; }
.top-list .sc b { display: block; color: var(--lime); font-size: 15px; }
.top-list .sc small { color: var(--dim); font-size: 11px; }

/* Desktop and tablets: sheets become centred panels */
@media (min-width: 720px) and (min-height: 560px) {
  .sheet { left: 50%; right: auto; width: 440px; transform: translateX(-50%); bottom: auto; top: 50%; translate: 0 -50%; max-height: min(80dvh, 720px); }
  #topSheet { top: 50%; height: min(80dvh, 720px); }
  .controls { gap: 40px; padding: 14px 0 10px; }
  .act { width: 76px; height: 76px; }
  .act.love { width: 88px; height: 88px; }
  .card { --w: min(100cqw, calc(100cqh - 100px), 560px); }
  .info { height: 100px; padding: 12px 18px 14px; }
  .num { font-size: 20px; } .name { font-size: 17px; }
  .traits span { font-size: 13px; padding: 4px 10px; }
}

/* Phone landscape and short screens: deck left, controls stacked right */
@media (orientation: landscape) and (max-height: 520px) {
  #app { grid-template: "top top" auto "stage controls" minmax(0, 1fr) "stage foot" auto / minmax(0, 1fr) auto; column-gap: 18px; }
  .top { min-height: 40px; }
  .icon { width: 40px; height: 40px; }
  .controls { flex-direction: column; gap: 14px; padding: 0 4px; }
  .act { width: 60px; height: 60px; }
  .act.love { width: 70px; height: 70px; }
  .toast { left: auto; right: calc(100% + 8px); bottom: 50%; transform: translate(6px, 50%); }
  .toast.on { transform: translate(0, 50%); }
  .card { --w: min(calc(100cqh * 1.45), 100cqw, 640px); display: grid; grid-template-columns: min(100cqh, 58%) 1fr; }
  .info { height: auto; border-top: 0; border-left: 1px solid rgba(124, 255, 107, .1); justify-content: center; }
  .traits { flex-wrap: wrap; }
  .title { flex-direction: column; gap: 2px; }
  .name { white-space: normal; }
  .stamp { top: 16px; font-size: 22px; }
  #topSheet { top: calc(var(--st) + 4px); }
  .foot { padding: 0 0 2px; }
}
@media (max-height: 600px) and (orientation: portrait) {
  .top { min-height: 42px; }
  .act { width: 58px; height: 58px; }
  .act.love { width: 66px; height: 66px; }
  .controls { padding: 6px 0 2px; }
  .card { --w: min(100cqw, calc(100cqh - 74px), 460px); }
  .info { height: 74px; padding: 8px 12px; gap: 4px; }
}
@media (max-width: 340px) {
  .word { font-size: 17px; }
  .tally { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .act, .toast { transition: none; }
  .act.hit { animation: none; }
}
.rank-note { margin: 0; padding: 8px 16px 14px; border-top: 1px solid var(--line); }
