@font-face { font-family: UnderworldDisplay; src: url('/fonts/heading.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }
:root {
  --bg: #090b0a; --s1: #131416; --s2: #1b1c1f; --s3: #24252a; --line: #2c2d31; --text: #ecebe4; --muted: #a8a89f;
  --lime: #c3ff5c; --lav: #b9a7ff; --coral: #ff6b5c; --ink: #0e0f0c;
  --r: 12px; --tap: 44px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: UnderworldDisplay, "Arial Narrow", Impact, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --st: env(safe-area-inset-top); --sb: env(safe-area-inset-bottom); --sl: env(safe-area-inset-left); --sr: env(safe-area-inset-right);
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.defs { position: absolute; }
svg { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.primary, .ghost, .pill, .chip, .card-btn, .seg button, .link { -webkit-user-select: none; user-select: none; transition: transform .15s var(--ease), background-color .15s var(--ease), opacity .15s var(--ease), border-color .15s var(--ease); }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px; border: 0; border-radius: var(--r); background: var(--lime); color: var(--ink); font-weight: 800; font-size: 16px; }
.primary small { font-weight: 700; font-size: 12px; opacity: .62; font-variant-numeric: tabular-nums; }
.ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); min-width: var(--tap); padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--s1); font-weight: 700; font-size: 14px; }
.ghost.icon { padding: 0; width: var(--tap); }
.ghost.wide, .primary.wide { width: 100%; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--s1); font-weight: 700; font-size: 13px; position: relative; }
.pill::after { content: ""; position: absolute; inset: -4px; }
.pill svg { width: 18px; height: 18px; }
.pill.holder { border-color: color-mix(in srgb, var(--lime) 55%, transparent); color: var(--lime); }
.link { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; min-height: var(--tap); padding: 0 6px; }
.primary:active, .ghost:active, .pill:active, .chip:active, .card-btn:active, .seg button:active { transform: scale(.96); }
.primary:disabled, .ghost:disabled { opacity: .45; pointer-events: none; }
@media (hover: hover) {
  .ghost:hover, .pill:hover, .chip:hover, .card-btn:hover { background: var(--s2); }
  .primary:hover { background: #d2ff7e; }
}

/* ---------- layout: phone first ---------- */
.app {
  height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  padding: calc(6px + var(--st)) calc(10px + var(--sr)) 0 calc(10px + var(--sl));
}
.top { display: flex; align-items: center; gap: 6px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; margin-right: auto; min-height: var(--tap); }
.brand .mark { width: 26px; height: 26px; image-rendering: pixelated; }
.word { font: 800 24px/1 var(--display); letter-spacing: .01em; text-transform: uppercase; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 6px 0 4px; border: 1px solid var(--line); border-radius: var(--r); background: var(--s1); font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; max-width: 46vw; }
.chip canvas { width: 34px; height: 34px; border-radius: 8px; background: var(--s3); image-rendering: pixelated; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip svg { width: 18px; height: 18px; color: var(--muted); }

.stage { display: grid; place-items: center; min-height: 0; padding: 8px 0; }
.art { position: relative; width: min(100%, 100cqh); aspect-ratio: 1; max-height: 100%; container-type: normal; }
.stage { container-type: size; }
.art { width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); }
#cv { display: block; width: 100%; height: 100%; border-radius: 6px; image-rendering: pixelated; box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .06); transition: transform .18s var(--ease), opacity .2s var(--ease); touch-action: pan-y; cursor: pointer; opacity: 0; }
#cv.on { opacity: 1; }
#cv.press { transform: scale(.985); }
.skeleton { position: absolute; inset: 0; display: grid; grid-template: 1fr 1fr / 1fr 1fr; gap: 0; border-radius: 6px; overflow: hidden; }
.skeleton i { background: linear-gradient(110deg, var(--s1) 30%, var(--s2) 50%, var(--s1) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton i:nth-child(2), .skeleton i:nth-child(3) { background-color: var(--s2); animation-delay: -.35s; }
@keyframes shimmer { to { background-position: -150% 0; } }
.art-error { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; background: var(--s1); border-radius: 6px; padding: 16px; }
.art-error p { margin: 0; color: var(--muted); }
.hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 999px; background: rgba(9, 11, 10, .86); color: var(--text); font-size: 13px; font-weight: 700; white-space: nowrap; pointer-events: none; animation: hint 3s var(--ease) forwards; }
@keyframes hint { 0% { opacity: 0; transform: translate(-50%, 6px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

.panel { display: grid; gap: 8px; padding: 4px 0 calc(10px + var(--sb)); }
.side-head, .side-foot .keys, .side-foot .sig { display: none; }
.side-foot { display: none; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: calc(var(--r) + 4px); background: var(--s1); border: 1px solid var(--line); }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 8px; border: 0; border-radius: var(--r); background: transparent; color: var(--muted); font-weight: 800; font-size: 14px; white-space: nowrap; }
.seg button svg { width: 18px; height: 18px; }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--s3); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.modes button[aria-selected="true"] svg { color: var(--lime); }
.seg.small { padding: 3px; flex: none; }
.seg.small button { min-height: 38px; min-width: 50px; font-size: 13px; padding: 0 10px; }
.seg .lk { width: 12px; height: 12px; margin-left: -2px; opacity: .7; }
.holderonly:not(.locked) .lk { display: none; }

.tune { min-height: 48px; display: grid; align-items: center; }
.tune .row { display: none; align-items: center; gap: 8px; min-width: 0; }
.tune .row.on { display: flex; animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.tune .row > .ghost:not(.icon) { flex: none; }
.swatches { display: flex; gap: 4px; flex: none; }
.swatch { width: var(--tap); height: var(--tap); border-radius: var(--r); border: 1px solid var(--line); background: var(--s1); padding: 6px; display: grid; place-items: center; }
.swatch i { display: grid; grid-template: 1fr 1fr / 1fr 1fr; width: 100%; height: 100%; border-radius: 5px; overflow: hidden; }
.swatch i b { display: block; }
.swatch[aria-checked="true"] { border-color: var(--lime); box-shadow: inset 0 0 0 1px var(--lime); }
.slider { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--s1); }
.slider span { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
input[type="range"] { flex: 1; min-width: 0; height: var(--tap); margin: 0; background: transparent; -webkit-appearance: none; appearance: none; touch-action: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--lime) var(--p, 50%), var(--s3) var(--p, 50%)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--s3); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--lime); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--text); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--line); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--text); border: 3px solid var(--bg); }

.acts { display: flex; gap: 8px; }
.acts .primary { flex: 1; min-height: 52px; border-radius: 14px; }

.card-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--s1); text-align: left; }
.card-btn span { display: grid; flex: 1; }
.card-btn b { font-size: 14px; }
.card-btn small { font-size: 12px; color: var(--muted); }
.card-btn > svg:first-child { color: var(--lav); }
.card-btn .go { width: 18px; height: 18px; color: var(--muted); }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; margin: 0 2px; border-radius: 5px; background: var(--s2); border: 1px solid var(--line); font: 700 12px/1 var(--font); vertical-align: middle; }
kbd svg { width: 12px; height: 12px; }
.sig { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; text-decoration: none; min-height: var(--tap); }
.sig svg { width: 16px; height: 16px; }
.sig:hover { color: var(--text); }

/* ---------- sheets ---------- */
dialog.sheet { position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 100%; max-height: min(86dvh, 640px); padding: 0; border: 0; border-radius: 20px 20px 0 0; background: var(--s1); color: var(--text); box-shadow: 0 -20px 60px rgba(0, 0, 0, .6); overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; animation: up .22s var(--ease); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .6); animation: fadein .2s var(--ease); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fadein { from { opacity: 0; } }
.sheet-in { overflow: auto; overscroll-behavior: contain; padding: 6px calc(16px + var(--sr)) calc(16px + var(--sb)) calc(16px + var(--sl)); display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--s1); padding-top: 8px; z-index: 1; }
.sheet-head::before { content: ""; position: absolute; top: 0; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
.sheet h2 { margin: 0; font: 800 22px/1.1 var(--display); text-transform: uppercase; letter-spacing: .01em; }
.sheet h3 { margin: 0 0 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.idrow { display: flex; gap: 6px; }
.idfield { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; min-height: var(--tap); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); font-weight: 800; }
.idfield span { color: var(--muted); }
.idfield input { flex: 1; min-width: 0; border: 0; background: none; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; outline: none; }
.idrow .primary { padding: 0 16px; }
.range { margin: -6px 0 0; font-size: 12px; color: var(--muted); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.thumbs button { position: relative; aspect-ratio: 1; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--s2); overflow: hidden; }
.thumbs button canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.thumbs button span { position: absolute; left: 4px; bottom: 3px; font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px #000; font-variant-numeric: tabular-nums; }
.thumbs button[aria-current="true"] { border-color: var(--lime); box-shadow: inset 0 0 0 1px var(--lime); }
.perks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perks li { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.perks svg { width: 18px; height: 18px; color: var(--lime); }
.holder-box, .buy { display: grid; gap: 12px; padding: 14px; border-radius: 16px; background: var(--s2); border: 1px solid var(--line); }
.holder-box.on { border-color: color-mix(in srgb, var(--lime) 40%, transparent); }
.status { margin: 0; font-size: 13px; color: var(--muted); }
.status.bad { color: var(--coral); }
.status.good { color: var(--lime); }
.buy-head { display: flex; gap: 12px; align-items: flex-start; }
.buy-head > svg { width: 28px; height: 28px; color: var(--lav); margin-top: 2px; }
.buy-head h3 { color: var(--text); font-size: 16px; text-transform: none; letter-spacing: 0; margin: 0 0 4px; }
.buy-head p { margin: 0; font-size: 13px; color: var(--muted); }
.buy-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.buy .link { justify-self: start; margin: -6px 0 -10px -6px; }
.wallets { display: grid; gap: 8px; }
.wallets button { justify-content: flex-start; width: 100%; }
.wallets img { width: 26px; height: 26px; border-radius: 6px; }

.toast { position: fixed; left: 50%; bottom: calc(150px + var(--sb)); transform: translate(-50%, 10px); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 999px; background: var(--text); color: var(--ink); font-weight: 800; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease), transform .2s var(--ease); z-index: 10; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 18px; height: 18px; }
.noscript { position: fixed; inset: 0; display: grid; place-content: center; }

/* ---------- small phones ---------- */
@media (max-width: 359px) {
  #perks-label { display: none; }
  .pill { padding: 0; width: var(--tap); min-height: var(--tap); justify-content: center; }
  .seg button { font-size: 13px; padding: 0 4px; gap: 4px; }
  .modes button svg { display: none; }
  .seg.small button { min-width: 44px; padding: 0 6px; }
  .tune .row > #remix-btn span { display: none; }
  .tune .row > #remix-btn { width: var(--tap); padding: 0; }
  .slider span { display: none; }
  .primary small { display: none; }
}

/* ---------- side panel: tablets, desktop and phones in landscape ---------- */
@media (min-width: 768px) and (min-aspect-ratio: 1/1), (min-width: 1024px), (orientation: landscape) and (max-height: 560px) and (min-width: 560px) {
  .app { grid-template-columns: minmax(0, 1fr) clamp(300px, 30vw, 380px); grid-template-rows: auto minmax(0, 1fr); column-gap: clamp(12px, 2.4vw, 40px); padding-bottom: calc(10px + var(--sb)); }
  .top { grid-column: 1 / -1; }
  .stage { grid-row: 2; padding: 4px 0 8px; }
  .panel { grid-row: 2; align-content: start; overflow: auto; overscroll-behavior: contain; padding: 4px 2px 8px; gap: 12px; scrollbar-width: thin; }
  .side-head { display: block; }
  .side-foot { display: grid; gap: 10px; }
  .side-foot .keys { display: block; margin: 0; font-size: 12px; color: var(--muted); line-height: 2; }
  .side-foot .sig { display: inline-flex; }
  .title { margin: 0; font: 800 clamp(34px, 4vw, 52px)/.95 var(--display); text-transform: uppercase; }
  .sub { margin: 4px 0 0; color: var(--muted); }
  .tune .row { flex-wrap: wrap; }
  .tune .row .slider { flex-basis: 100%; }
  .toast { bottom: calc(24px + var(--sb)); }
  dialog.sheet { inset: 0; margin: auto; width: min(460px, calc(100vw - 32px)); max-height: min(86dvh, 680px); border-radius: 20px; height: fit-content; }
  dialog.sheet[open] { animation: pop .2s var(--ease); }
  .sheet-head::before { display: none; }
  @keyframes pop { from { transform: scale(.97); opacity: 0; } }
}
/* Phones in landscape: compact the side panel. */
@media (orientation: landscape) and (max-height: 560px) {
  .top { min-height: 44px; }
  .side-head, .side-foot .keys { display: none; }
  .panel { gap: 8px; }
  .acts .primary { min-height: 46px; }
  .card-btn { min-height: 48px; }
}
@media (min-width: 1280px) {
  .app { padding-left: calc(24px + var(--sl)); padding-right: calc(24px + var(--sr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #cv { transition: opacity .2s linear !important; }
  .hint { animation: none; }
  .skeleton i { animation: none; }
}
