:root {
  --bg: #150e22;
  --ink: #fff4e2;
  --muted: #d9bf9f;
  --dim: #a88c70;
  --panel: rgba(40, 23, 14, 0.84);
  --panel-2: rgba(62, 37, 22, 0.9);
  --edge: #120904;
  --line: rgba(255, 214, 170, 0.14);
  --acorn: #ff9a2e;
  --acorn-2: #ffc35a;
  --buy: #5be38d;
  --sell: #ff6070;
  --gold: #ffd23f;
  --display: "Lilita One", "Nunito", system-ui, sans-serif;
  --body: "Nunito", system-ui, sans-serif;
  --gut: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 800 14px/1.35 var(--body); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, a { font: inherit; color: inherit; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }

.card { background: var(--panel); border: 2px solid var(--edge); border-radius: 18px; box-shadow: 0 5px 0 var(--edge), inset 0 1px 0 rgba(255, 220, 180, 0.12); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* brand */
#brand { position: absolute; left: max(var(--gut), env(safe-area-inset-left)); top: max(var(--gut), env(safe-area-inset-top)); display: grid; gap: 6px; justify-items: start; pointer-events: none; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo svg { width: 46px; height: 46px; filter: drop-shadow(0 4px 0 var(--edge)); transform: rotate(-10deg); }
#brand h1 { margin: 0; font: 400 52px/0.9 var(--display); letter-spacing: 0.02em; color: var(--acorn-2);
  -webkit-text-stroke: 2px var(--edge); paint-order: stroke fill; text-shadow: 0 5px 0 var(--edge), 0 10px 26px rgba(0, 0, 0, 0.45); }
.tags { display: flex; gap: 6px; align-items: center; }
.tick { font: 400 18px/1 var(--display); letter-spacing: 0.04em; background: var(--ink); color: #2a1409; padding: 5px 10px 4px; border-radius: 10px; border: 2px solid var(--edge); box-shadow: 0 3px 0 var(--edge); }
.live { display: inline-flex; align-items: center; gap: 6px; font: 900 12px/1 var(--body); letter-spacing: 0.12em; background: var(--panel); border: 2px solid var(--edge); border-radius: 10px; padding: 6px 9px; }
.live i, .trades h2 i { width: 8px; height: 8px; border-radius: 50%; background: var(--buy); box-shadow: 0 0 0 0 rgba(91, 227, 141, 0.6); animation: ping 1.6s infinite; }
.live.off i { background: var(--dim); animation: none; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(91, 227, 141, 0); } 100% { box-shadow: 0 0 0 0 rgba(91, 227, 141, 0); } }
.badge { font: 900 12px/1 var(--body); letter-spacing: 0.12em; color: #1a0d06; padding: 7px 10px; border-radius: 9px; border: 2px solid var(--edge); box-shadow: 0 3px 0 var(--edge);
  background: repeating-linear-gradient(-45deg, var(--gold) 0 12px, #ffe07a 12px 24px); }

/* right column */
#side { position: absolute; right: max(var(--gut), env(safe-area-inset-right)); top: max(var(--gut), env(safe-area-inset-top)); width: 318px; display: grid; gap: 12px; }
.mc { padding: 14px 16px 12px; }
.mc .k { font: 900 12px/1 var(--body); letter-spacing: 0.16em; color: var(--muted); }
.mc .v { font: 400 46px/1.05 var(--display); letter-spacing: 0.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.mc .sub { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 2px; }
.chip { font: 900 13px/1 var(--body); padding: 5px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.08); color: var(--muted); white-space: nowrap; }
.chip.up { background: rgba(91, 227, 141, 0.16); color: var(--buy); }
.chip.down { background: rgba(255, 96, 112, 0.16); color: var(--sell); }
.more { display: none; }
#stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 12px 0 0; padding-top: 10px; border-top: 2px dashed var(--line); }
#stats div { display: grid; gap: 1px; }
#stats dt { font: 900 11px/1.2 var(--body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
#stats dd { margin: 0; font: 900 16px/1.2 var(--body); font-variant-numeric: tabular-nums; }
#stats div:last-child { grid-column: 1 / -1; }

.nuts { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; border-radius: 999px; border: 2px solid var(--edge); box-shadow: 0 5px 0 var(--edge);
  background: linear-gradient(180deg, var(--acorn-2), var(--acorn)); color: #2a1409; font: 900 15px/1 var(--body); }
.nuts svg { width: 30px; height: 30px; flex: none; }
.nuts b { margin-left: auto; font: 400 28px/1 var(--display); background: #2a1409; color: var(--acorn-2); padding: 4px 12px 3px; border-radius: 999px; min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.nuts.bump b { animation: bump 0.7s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes bump { 30% { transform: scale(1.45) rotate(-6deg); } }

.trades { padding: 12px 12px 8px; }
.trades h2 { margin: 0 4px 8px; display: flex; align-items: center; gap: 8px; font: 900 12px/1 var(--body); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
#tl { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; max-height: calc(100vh - 470px); overflow: hidden; }
#tl li { display: grid; grid-template-columns: 44px 1fr auto 34px; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 10px; font-variant-numeric: tabular-nums; font-size: 13px; }
#tl li.empty { display: block; color: var(--dim); padding: 8px 6px; }
#tl .side { font: 900 11px/1 var(--body); letter-spacing: 0.08em; text-align: center; padding: 4px 0; border-radius: 6px; }
#tl .buy .side { background: rgba(91, 227, 141, 0.16); color: var(--buy); }
#tl .sell .side { background: rgba(255, 96, 112, 0.16); color: var(--sell); }
#tl .usd { font: 900 15px/1 var(--body); }
#tl .buy .usd { color: var(--buy); } #tl .sell .usd { color: var(--sell); }
#tl .who { color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tl .age { color: var(--dim); font-size: 12px; text-align: right; }
#tl li.whale { background: linear-gradient(90deg, rgba(255, 210, 63, 0.26), rgba(255, 210, 63, 0.06)); box-shadow: inset 0 0 0 2px rgba(255, 210, 63, 0.55); }
#tl li.whale .who::before { content: "WHALE "; color: var(--gold); font-weight: 900; }
#tl li.new { animation: slidein 0.45s ease-out; }
@keyframes slidein { from { transform: translateX(22px); opacity: 0; } }

/* bottom bar */
#bar { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(var(--gut), env(safe-area-inset-bottom)); width: min(920px, calc(100% - 2 * var(--gut)));
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
#bar { background: var(--panel); border: 2px solid var(--edge); border-radius: 20px; box-shadow: 0 5px 0 var(--edge); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.heat { flex: 1; min-width: 0; }
.heat .row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; gap: 10px; }
.word { font: 400 24px/1 var(--display); letter-spacing: 0.02em; text-transform: lowercase; color: var(--acorn-2); white-space: nowrap; transition: color 0.3s; }
.word.hot { color: #ff6a8a; text-transform: none; animation: wobble 0.35s infinite alternate; }
.word.busted { color: var(--gold); }
.word.sleep { color: #9fc6ff; }
@keyframes wobble { to { transform: translateX(2px) rotate(-1deg); } }
.hv { color: var(--muted); font-size: 12px; white-space: nowrap; }
.hv b { font: 400 20px/1 var(--display); color: var(--ink); margin-right: 2px; font-variant-numeric: tabular-nums; }
.meter { position: relative; height: 16px; border-radius: 999px; background: rgba(0, 0, 0, 0.42); border: 2px solid var(--edge); overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; width: 10%; border-radius: 999px; background: linear-gradient(90deg, #8fd0ff, var(--buy) 25%, var(--acorn-2) 50%, var(--acorn) 72%, #ff4f7e); background-size: 100vw 100%; }
.meter s { position: absolute; top: 2px; bottom: 2px; width: 2px; background: rgba(255, 244, 226, 0.25); }
.btns { display: flex; gap: 8px; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 900 14px/1 var(--body); padding: 11px 14px; border-radius: 12px; border: 2px solid var(--edge);
  box-shadow: 0 4px 0 var(--edge); background: var(--panel-2); color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform 0.08s, box-shadow 0.08s; }
.btn:hover:not(:disabled):not([aria-disabled="true"]) { transform: translateY(-1px); box-shadow: 0 5px 0 var(--edge); }
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.btn.primary { background: linear-gradient(180deg, #7cf0a6, #3fcf76); color: #0d2716; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: default; }
.btn.icon svg { width: 18px; height: 18px; }
:focus-visible { outline: 3px solid var(--acorn-2); outline-offset: 2px; }

/* finish moment */
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: #fff; }
#flash.go { animation: flash 1.8s ease-out; }
/* bust-v2: pure white hold ~0.4s (0-22%), fades, then a second smaller pulse ~0.5s after the hold
   ends (50-62%) before finishing the fade — a double flash, not a single decay. */
@keyframes flash { 3% { opacity: 1; } 22% { opacity: 1; } 50% { opacity: 0.12; } 62% { opacity: 0.5; } 100% { opacity: 0; } }
#toast { position: fixed; left: 50%; top: 24%; transform: translate(-50%, 0); display: grid; justify-items: center; gap: 8px; pointer-events: none; opacity: 0; text-align: center; width: max-content; max-width: calc(100% - 32px); }
#toast b { font: 400 clamp(46px, 10vw, 104px)/0.9 var(--display); color: var(--acorn-2); -webkit-text-stroke: 3px var(--edge); paint-order: stroke fill; text-shadow: 0 7px 0 var(--edge), 0 16px 40px rgba(0, 0, 0, 0.5); letter-spacing: 0.02em; }
#toast span { font: 900 clamp(15px, 2.4vw, 22px)/1.2 var(--body); background: var(--edge); color: var(--ink); padding: 8px 14px; border-radius: 12px; }
#toast.go { animation: toast 3.6s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 30px) scale(0.5) rotate(-8deg); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1.08) rotate(-3deg); } 20% { transform: translate(-50%, 0) scale(1) rotate(-2deg); } 82% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -20px) scale(0.96) rotate(-2deg); } }

/* debug */
#debug { position: fixed; left: max(var(--gut), env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); display: grid; gap: 6px; padding: 10px; background: rgba(10, 6, 20, 0.88); border: 2px dashed #ff5fd2; border-radius: 12px; z-index: 5; }
#debug b { font: 900 11px/1 var(--body); letter-spacing: 0.18em; color: #ff5fd2; }
#debug button { font: 800 13px/1 var(--body); padding: 8px 10px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.2); background: #2a1f3f; color: #fff; cursor: pointer; text-align: left; }
#debug button:hover { background: #3b2d5a; }
#debug output { font: 700 11px/1.3 ui-monospace, monospace; color: #cfc3ff; white-space: pre; }

/* stream mode: 1920x1080 OBS overlay. Everything sits at the edges so the centre stays
   clear for Nutty; #progress (level badge + next-bust meter) is hud.js/hud.css territory —
   only its container is repositioned/sized here, not its owned inner rules. */
body.stream #debug { display: none; }
body.stream #bar, body.stream .trades, body.stream .more, body.stream #stats { display: none; }
body.stream #brand { transform: scale(0.82); transform-origin: top left; }
body.stream #side { width: 400px; gap: 18px; }
body.stream .mc { padding: 24px 28px 22px; }
body.stream .mc .k { font-size: 17px; letter-spacing: 0.18em; }
body.stream .mc .v { font-size: 74px; }
body.stream .mc .sub { font-size: 19px; }
body.stream .chip { font-size: 16px; padding: 7px 11px; }
body.stream .nuts { font-size: 20px; padding: 11px 15px 11px 11px; }
body.stream .nuts svg { width: 38px; height: 38px; }
body.stream .nuts b { font-size: 34px; padding: 6px 15px 5px; min-width: 64px; }
body.stream #progress { padding: 20px 24px; }

#ticker-strip { position: fixed; left: 12px; bottom: 12px; font: 900 16px/1 var(--body); background: rgba(20, 11, 6, 0.85); border: 2px solid var(--edge); border-radius: 12px; padding: 9px 12px; display: flex; gap: 12px; align-items: center; }
#ticker-strip b { font: 400 18px/1 var(--display); color: var(--acorn-2); }
#ticker-strip .buy { color: var(--buy); } #ticker-strip .sell { color: var(--sell); }
#ticker-strip .demo { color: #1a0d06; background: var(--gold); padding: 3px 6px; border-radius: 6px; font-size: 11px; letter-spacing: 0.1em; }
/* stream: a full-width bottom ticker in large type, clear of the centre */
body.stream #ticker-strip { left: 0; right: 0; bottom: 0; top: auto; width: 100%; border-width: 3px 0 0 0; border-radius: 0;
  justify-content: center; padding: 20px 32px; font-size: 26px; gap: 30px; }
body.stream #ticker-strip b { font-size: 32px; }
body.stream #ticker-strip .demo { font-size: 15px; padding: 5px 10px; }

#gl-lost { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgba(21, 14, 34, 0.9); z-index: 10; }
#gl-lost[hidden] { display: none; }
#gl-lost button { font: 900 16px var(--body); padding: 10px 18px; border-radius: 12px; border: 2px solid var(--edge); background: var(--acorn); color: #1a0d06; cursor: pointer; }
.nojs { position: fixed; inset: 0; display: grid; place-content: center; }
[hidden] { display: none !important; }

/* tablet */
@media (max-width: 900px) {
  #side { width: 280px; }
  .mc .v { font-size: 38px; }
  .btn .long { display: none; }
  #brand h1 { font-size: 44px; }
}
/* phone */
@media (max-width: 640px) {
  :root { --gut: 12px; }
  #brand { gap: 5px; }
  .logo svg { width: 32px; height: 32px; }
  #brand h1 { font-size: 34px; -webkit-text-stroke-width: 1.5px; text-shadow: 0 3px 0 var(--edge); }
  .tick { font-size: 14px; padding: 4px 7px 3px; }
  .live { font-size: 10px; padding: 5px 7px; }
  .badge { font-size: 9.5px; padding: 5px 7px; letter-spacing: 0.08em; max-width: 150px; line-height: 1.25; }
  #side { width: min(186px, 50vw); gap: 9px; }
  .card { border-radius: 14px; box-shadow: 0 4px 0 var(--edge); }
  .mc { padding: 10px 11px 9px; }
  .mc .k { font-size: 10px; }
  .mc .v { font-size: 30px; }
  .mc .sub { font-size: 11px; flex-wrap: wrap; gap: 4px; }
  .chip { font-size: 11px; padding: 4px 6px; }
  .more { display: block; margin-top: 7px; width: 100%; font: 900 11px/1 var(--body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); background: rgba(255, 255, 255, 0.06); border: 0; border-radius: 8px; padding: 6px; cursor: pointer; }
  .more::after { content: " ▾"; }
  .more[aria-expanded="true"]::after { content: " ▴"; }
  #stats { display: none; grid-template-columns: 1fr; gap: 5px; margin-top: 8px; padding-top: 8px; }
  #stats.open { display: grid; }
  #stats div { grid-template-columns: 1fr auto; align-items: baseline; }
  #stats dd { font-size: 13px; }
  .nuts { padding: 5px 6px 5px 5px; gap: 6px; font-size: 12px; box-shadow: 0 4px 0 var(--edge); }
  .nuts svg { width: 22px; height: 22px; }
  .nuts b { font-size: 20px; min-width: 38px; padding: 3px 8px 2px; }
  .trades { padding: 8px 7px 5px; }
  .trades h2 { font-size: 10px; margin-bottom: 5px; }
  #tl { max-height: none; }
  #tl li { grid-template-columns: 1fr auto; gap: 4px; padding: 3px 5px; font-size: 11px; }
  #tl li:nth-child(n + 5) { display: none; }
  #tl .side, #tl .who { display: none; }
  #tl .usd { font-size: 13px; }
  #tl li.whale .usd::before { content: "★ "; color: var(--gold); }
  #bar { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px; border-radius: 16px; }
  .word { font-size: 20px; }
  .btns { display: grid; grid-template-columns: 1.3fr 1fr 0.7fr 0.6fr; gap: 7px; }
  .btn { padding: 10px 6px; font-size: 13px; }
  #toast { top: 30%; }
  #debug { top: auto; bottom: 150px; transform: none; grid-template-columns: 1fr 1fr; }
  #debug b, #debug output { grid-column: 1 / -1; }
}
@media (max-height: 560px) and (min-width: 641px) { .trades { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  #flash.go { animation: flashsoft 1.8s ease-out !important; }
  #toast.go { animation: toastsoft 3.4s linear forwards !important; }
  @keyframes flashsoft { 10% { opacity: 0.35; } 100% { opacity: 0; } }
  @keyframes toastsoft { 0% { opacity: 0; } 8% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } }
}

/* level-up banner */
.levelup { position: fixed; left: 0; right: 0; top: 34%; display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; padding: 16px 20px;
  background: linear-gradient(90deg, rgba(255, 154, 46, 0) 0, rgba(255, 154, 46, 0.95) 12%, rgba(255, 210, 63, 0.97) 50%, rgba(255, 154, 46, 0.95) 88%, rgba(255, 154, 46, 0) 100%);
  border-block: 4px solid var(--edge); pointer-events: none; opacity: 0; z-index: 4; transform: scaleY(0); }
.levelup small { font: 900 clamp(14px, 2vw, 22px)/1 var(--body); letter-spacing: 0.2em; color: #2a1409; background: var(--ink); padding: 6px 10px; border-radius: 8px; border: 3px solid var(--edge); }
.levelup b { font: 400 clamp(34px, 7vw, 84px)/0.95 var(--display); color: #fff8e8; -webkit-text-stroke: 3px var(--edge); paint-order: stroke fill; text-shadow: 0 6px 0 var(--edge); text-align: center; }
.levelup span { font: 400 clamp(24px, 4vw, 48px)/1 var(--display); color: #2a1409; }
.levelup.go { animation: lvup 4.2s cubic-bezier(.2, 1.3, .4, 1) forwards; }
@keyframes lvup { 0% { opacity: 0; transform: scaleY(0) rotate(-2deg); } 10% { opacity: 1; transform: scaleY(1.1) rotate(-2deg); } 16% { transform: scaleY(1) rotate(-2deg); } 85% { opacity: 1; transform: scaleY(1) rotate(-2deg); } 100% { opacity: 0; transform: scaleY(0.6) rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) { .levelup.go { animation: toastsoft 4s linear forwards !important; transform: none; } }
