:root {
  --ink: #040001;
  --paper: #fff;
  --magenta: #FB03BB;
  --lime: #DDFD4B;
  --purple: #8A00F9;
  --grey: #B7B7B7;
  --pad: 12px;
  --bar: 60px;
  --tick: 38px;
}
* { box-sizing: border-box; margin: 0; padding: 0; font: inherit; color: inherit; }
html, body { height: 100%; background: var(--ink); overflow: hidden; overscroll-behavior: none; }
body {
  font-family: "Archivo", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-stretch: 62%; font-weight: 800; line-height: 1.1; color: var(--ink);
  -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
}
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--magenta); outline-offset: 2px; }

/* ---------- buttons ---------- */
button, .btn, .sheet input, .sheet textarea {
  border: 2px solid var(--ink); background: var(--paper); padding: 10px 12px 8px; font-size: 18px; text-transform: uppercase;
}
button, .btn { cursor: pointer; background: var(--ink); color: var(--paper); text-decoration: none; text-align: center; display: inline-block; }
button:hover, .btn:hover { background: var(--magenta); border-color: var(--magenta); color: var(--paper); }
button:disabled { opacity: .5; cursor: wait; }
.go { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.ghost { background: transparent; color: var(--paper); border-color: var(--paper); }
.go:active, .ghost:active, .btn:active { translate: 1px 1px; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 100; background: var(--ink); color: var(--paper); overflow: hidden;
  display: grid; place-items: center; clip-path: inset(0 0 0 0);
}
#loader.out { animation: loader-out .75s cubic-bezier(.7, 0, .3, 1) forwards; }
@keyframes loader-out { to { clip-path: inset(0 0 100% 0); } }
.loader-giant {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: min(40vh, 31vw); line-height: .8; letter-spacing: -.035em; font-weight: 900; white-space: nowrap;
  padding-bottom: 12vh;
}
.loader-giant span { animation: breathe 4s ease-in-out infinite; }
.loader-giant span + span { color: var(--magenta); animation-delay: -2s; }
@keyframes breathe { 50% { scale: 1.03; } }
.loader-body {
  position: relative; width: clamp(130px, 18vw, 220px); padding: 10px; background: var(--lime); margin-bottom: 12vh;
  rotate: -5deg; animation: bob 3.2s ease-in-out infinite;
}
.loader-body canvas { display: block; width: 100%; aspect-ratio: 4 / 5; background: var(--magenta); }
@keyframes bob { 50% { translate: 0 -14px; rotate: 4deg; } }
.loader-ui {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 20px 16px max(28px, env(safe-area-inset-bottom));
}
.meter { width: min(560px, 100%); height: 16px; border: 3px solid var(--paper); }
.meter i { display: block; height: 100%; width: var(--p, 0%); background: var(--lime); transition: width .35s ease-out; }
.loader-line { font-size: 24px; text-align: center; }
.loader-line .pct { color: var(--lime); font-weight: 900; }
.loader-line .msg { color: var(--grey); }
.loader-err { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; font-size: 20px; color: var(--magenta); }
.loader-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; animation: rise .5s cubic-bezier(.3, 1.4, .5, 1) both; }
.loader-actions button { font-size: 26px; padding: 16px 24px 13px; }
@keyframes rise { from { translate: 0 30px; opacity: 0; } }

/* ---------- top bar ---------- */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10; height: var(--bar);
  display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--ink); color: var(--paper);
  border-bottom: 3px solid var(--magenta);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 24px; font-weight: 900; letter-spacing: -.01em; }
.logo i { width: 26px; height: 26px; background: var(--magenta); border: 4px solid var(--lime); flex: none; }
.alive { display: flex; align-items: center; gap: 0; font-size: 17px; color: var(--grey); white-space: nowrap; }
.alive i { width: 10px; height: 10px; border-radius: 50%; background: var(--lime); margin-right: 8px; animation: pulse 1.6s ease-out infinite; }
.alive b { color: var(--lime); font-weight: 900; }
.alive.bump b { animation: bump .6s cubic-bezier(.3, 1.8, .5, 1); display: inline-block; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(221 253 75 / .8); } 100% { box-shadow: 0 0 0 10px rgb(221 253 75 / 0); } }
@keyframes bump { 40% { scale: 1.6; color: var(--magenta); } }
.actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.actions button { font-size: 17px; padding: 8px 14px 6px; white-space: nowrap; }
.actions .icon { padding: 6px 8px; line-height: 0; }
.mute .cross, .mute.muted .waves { display: none; }
.mute.muted .cross { display: inline; }
.connect-btn.on { border-color: var(--lime); color: var(--lime); }

/* ---------- board ---------- */
.giant {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--paper); font-size: min(50vh, 32vw); line-height: .8; letter-spacing: -.035em; font-weight: 900;
  pointer-events: none; white-space: nowrap;
}
.giant span { will-change: transform; }
#board { position: fixed; inset: 0; z-index: 1; overflow: hidden; }
#arcs { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; overflow: visible; }
.arc { fill: none; stroke-width: 4; stroke-dasharray: 12 10; animation: march .5s linear infinite; transition: opacity .8s; }
.arc-dot { stroke: var(--ink); stroke-width: 3; transition: opacity .8s; }
@keyframes march { to { stroke-dashoffset: -22; } }
#fx { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
#fx i { position: absolute; width: 12px; height: 12px; }

.card { position: absolute; left: 0; top: 0; width: 300px; touch-action: none; cursor: grab; will-change: transform; }
.card.held { cursor: grabbing; }
.card-in {
  position: relative; padding: 14px; background: var(--b);
  transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .3s ease-out, scale .2s, box-shadow .2s;
}
.card.held .card-in { scale: 1.05; box-shadow: 16px 18px 0 rgb(0 0 0 / .5); }
.card canvas { display: block; width: 100%; aspect-ratio: 4 / 5; background: var(--f); }
.card .label {
  position: absolute; left: 28px; right: 28px; bottom: 26px; padding: 6px 10px 4px;
  background: var(--b); color: var(--t); font-size: 17px; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .label b { font-weight: 900; }
.card:hover .label, .card:focus-visible .label { background: var(--paper); color: var(--ink); }
.card .house { position: absolute; top: 24px; left: 24px; background: var(--ink); color: var(--paper); font-size: 12px; padding: 3px 6px 1px; }
.card.wake .card-in { animation: wake .8s cubic-bezier(.3, .7, .4, 1); }
@keyframes wake {
  0% { translate: 0 0; box-shadow: 0 0 0 0 var(--b); }
  10% { translate: -7px 2px; } 20% { translate: 7px -3px; } 30% { translate: -5px -2px; }
  40% { translate: 4px 3px; scale: 1.06; } 55% { translate: -2px 0; }
  100% { translate: 0 0; scale: 1; box-shadow: 0 0 0 28px transparent; }
}
.card-in::after { content: ""; position: absolute; inset: 0; background: var(--paper); opacity: 0; pointer-events: none; }
.card.flash .card-in::after { animation: flash .7s ease-out; }
@keyframes flash { from { opacity: 1; } }

.bubble {
  position: absolute; left: 50%; bottom: calc(100% + 16px); translate: -50% 0; width: max-content; max-width: min(320px, 82vw);
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--b);
  padding: 10px 12px 8px; font-size: 16px; font-weight: 600; font-stretch: 85%; line-height: 1.25;
  pointer-events: none; transform-origin: 50% 100%; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) both; transition: opacity .6s;
}
.bubble .txt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.bubble em { font-style: normal; font-weight: 900; background: var(--b); color: var(--t); padding: 1px 5px 0; margin-right: 4px; }
.bubble::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -11px; border: 11px solid transparent; border-top-color: var(--ink); }
.bubble.below { bottom: auto; top: calc(100% + 16px); transform-origin: 50% 0; }
.bubble.below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--ink); }
.bubble.gone { opacity: 0; }
@keyframes pop { from { scale: .3; opacity: 0; } }

/* ---------- how strip + ticker ---------- */
.how {
  position: fixed; left: 12px; bottom: calc(var(--tick) + 10px); z-index: 4; display: flex; gap: 6px; list-style: none;
  pointer-events: none; font-size: 14px; color: var(--grey);
}
.how li { background: rgb(4 0 1 / .85); border: 1px solid #3b2a35; padding: 5px 8px 3px; }
.how b { color: var(--lime); font-weight: 900; }
.ticker {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: var(--tick); display: flex; align-items: stretch;
  background: var(--lime); color: var(--ink); border-top: 3px solid var(--ink); font-size: 17px;
}
.ticker-label { flex: none; display: flex; align-items: center; padding: 2px 12px 0; background: var(--magenta); color: var(--paper); font-weight: 900; }
.ticker-win { flex: 1; overflow: hidden; display: flex; align-items: center; }
.ticker-track { display: flex; white-space: nowrap; will-change: transform; padding-top: 2px; }
.ticker-track span { padding-right: 36px; font-weight: 600; font-stretch: 80%; }
.ticker-track span::before { content: "●"; color: var(--magenta); margin-right: 10px; }
.ticker-track b { font-weight: 900; }

/* ---------- sheets ---------- */
.sheet {
  margin: auto; border: 0; background: transparent; max-width: min(1000px, calc(100vw - 2 * var(--pad)));
  width: 100%; max-height: calc(100dvh - 2 * var(--pad));
}
.sheet[open] { animation: sheet-in .35s cubic-bezier(.2, 1.3, .5, 1); }
@keyframes sheet-in { from { translate: 0 40px; scale: .96; opacity: 0; } }
.sheet::backdrop { background: rgb(4 0 1 / .78); }
.sheet-frame {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; background: var(--b, var(--lime));
  max-height: calc(100dvh - 2 * var(--pad));
}
.sheet-view { width: 100%; height: 100%; min-height: 360px; background: var(--f, var(--magenta)); display: block; }
.sheet-body {
  background: var(--paper); padding: 22px; overflow: auto; display: flex; flex-direction: column; gap: 12px;
  user-select: text; -webkit-user-select: text;
}
.sheet h2 { font-size: clamp(40px, 6vw, 72px); line-height: .85; letter-spacing: -.02em; font-weight: 900; text-transform: uppercase; }
.sheet h3 { font-size: 22px; margin-top: 8px; }
.sheet h3 small { font-size: 12px; background: var(--magenta); color: var(--paper); padding: 2px 6px 0; vertical-align: middle; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sheet .tick { font-size: 22px; background: var(--b, var(--lime)); color: var(--t, var(--ink)); padding: 4px 8px 2px; }
.badge { background: var(--ink); color: var(--lime); font-size: 16px; padding: 6px 8px 4px; }
.sheet .persona { font-weight: 500; font-stretch: 85%; font-size: 17px; line-height: 1.35; }
.sheet .x { position: sticky; top: 0; align-self: flex-end; z-index: 1; background: var(--paper); color: var(--ink); padding: 6px 10px 4px; font-size: 16px; }
.sheet .x:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.links .btn, .links button { font-size: 17px; padding: 8px 12px 6px; }
.links .pump { background: var(--lime); color: var(--ink); border-color: var(--ink); }
.chat { display: flex; flex-direction: column; gap: 6px; padding: 12px; background: var(--ink); color: var(--paper); }
.chat label { font-size: 18px; color: var(--lime); }
.chat-row { display: flex; gap: 8px; }
.chat input { flex: 1; min-width: 0; border-color: var(--paper); }
.chat button { border-color: var(--lime); }
.thoughts { list-style: none; display: flex; flex-direction: column; gap: 8px; font-weight: 500; font-stretch: 85%; font-size: 16px; line-height: 1.35; }
.thoughts li { border-left: 4px solid var(--b, var(--lime)); padding-left: 10px; }
.thoughts li.you { border-color: var(--ink); opacity: .7; }
.thoughts li.new { animation: rise .4s ease-out; }
.thoughts time { display: block; font-size: 12px; opacity: .55; font-weight: 700; }
.dots::after { content: "..."; animation: dots 1s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } }

.sheet textarea, .sheet input { width: 100%; text-transform: none; font-weight: 600; font-stretch: 85%; color: var(--ink); background: var(--paper); }
.sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 16px; }
.step { border: 3px solid var(--ink); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.step h3 { display: flex; align-items: center; gap: 10px; font-size: 26px; margin: 0; }
.step h3 i { font-style: normal; width: 36px; height: 36px; display: grid; place-items: center; background: var(--ink); color: var(--paper); padding-top: 3px; }
.step.done h3 i { background: var(--lime); color: var(--ink); font-size: 0; }
.step.done h3 i::before { content: "✓"; font-size: 22px; }
.wallet-line { font-size: 18px; }
.hint { font-size: 13px; font-weight: 600; opacity: .6; }
.status { font-size: 20px; line-height: 1.2; min-height: 1em; word-break: break-word; }
.status.ok { background: var(--lime); padding: 8px 10px 6px; }
.status.err { background: var(--magenta); color: var(--paper); padding: 8px 10px 6px; }
.status.busy::after { content: " ●"; color: var(--magenta); animation: blink .8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.launch-go { font-size: 24px; padding: 14px; }

@media (min-width: 768px) { :root { --pad: 4rem; } }
@media (max-width: 720px) {
  :root { --bar: 54px; --tick: 34px; }
  .wide, .logo span { display: none; }
  .bar { gap: 10px; padding: 0 10px; }
  .actions { gap: 6px; }
  .actions button { font-size: 15px; padding: 7px 9px 5px; }
  .alive { font-size: 15px; }
  .card { width: 180px; }
  .card-in { padding: 9px; }
  .card .label { left: 16px; right: 16px; bottom: 16px; font-size: 13px; }
  .card .house { top: 15px; left: 15px; font-size: 10px; }
  .bubble { font-size: 14px; max-width: min(240px, 80vw); }
  .how { font-size: 12px; left: 8px; }
  .ticker { font-size: 15px; }
  .sheet-frame { grid-template-columns: 1fr; overflow: auto; padding: 10px; gap: 10px; }
  .sheet-view { min-height: 200px; height: 200px; }
  .sheet-body { padding: 14px; overflow: visible; }
  .loader-actions button { font-size: 21px; padding: 14px 16px 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .alive i { animation: none; }
}
