:root {
  --bg: #07080b;
  --bg2: #0d1016;
  --panel: #10141c;
  --line: #1d2330;
  --text: #d8dee9;
  --dim: #6b7486;
  --long: #19ff8c;
  --short: #ff2e55;
  --gold: #ffc23d;
  --cyan: #3de0ff;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --disp: "Bebas Neue", Impact, sans-serif;
  --mode: var(--long);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--mono); overflow: hidden; }
body.short { --mode: var(--short); }
button { font: inherit; cursor: pointer; }
kbd { font-family: var(--mono); }

#app { display: grid; grid-template-rows: 52px 1fr 74px; height: 100vh; }

/* ---------- top bar ---------- */
#top { display: flex; align-items: center; gap: 14px; padding: 0 16px; border-bottom: 1px solid var(--line); background: linear-gradient(#0b0e14, var(--bg)); }
.logo { display: flex; align-items: center; gap: 8px; font-family: var(--disp); font-size: 28px; letter-spacing: 2px; }
.logo svg { width: 26px; height: 26px; fill: var(--mode); animation: spin 8s linear infinite; filter: drop-shadow(0 0 6px var(--mode)); }
.logo svg circle, .bigStar circle { fill: var(--bg); }
.logo b, h1 b { color: var(--mode); font-weight: normal; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { font-family: var(--disp); font-size: 18px; letter-spacing: 1.5px; padding: 3px 10px 1px; border: 1px solid var(--line); border-radius: 3px; color: var(--dim); }
#brokerBadge.live { color: #000; background: var(--gold); border-color: var(--gold); box-shadow: 0 0 14px rgba(255,194,61,.5); }
.status.ok { color: var(--long); border-color: rgba(25,255,140,.4); }
.status.bad { color: #fff; background: var(--short); border-color: var(--short); animation: blink 1s steps(2) infinite; }
.status.warn { color: #000; background: var(--gold); border-color: var(--gold); }
@keyframes blink { 50% { opacity: .55; } }
.topstat { display: flex; flex-direction: column; line-height: 1.05; }
.topstat label { font-size: 9px; color: var(--dim); letter-spacing: 1.5px; }
.topstat span { font-size: 15px; font-weight: 700; }
.spacer { flex: 1; }
.ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); border-radius: 3px; padding: 5px 10px; font-size: 11px; letter-spacing: 1px; }
.ghost:hover { color: var(--text); border-color: var(--dim); }
.ghost.tiny { padding: 2px 6px; font-size: 9px; }

/* ---------- stage ---------- */
#stage { display: grid; grid-template-columns: 1fr 330px; min-height: 0; }
#chartWrap { position: relative; min-width: 0; border-right: 1px solid var(--line); background: var(--bg); overflow: hidden; }
#backdrop { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: .55; pointer-events: none; }
#chart { position: absolute; inset: 0; z-index: 1; }
#chartWrap::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(0,0,0,.65); }

#modeBanner { position: absolute; top: 14px; left: 16px; z-index: 5; display: flex; align-items: baseline; gap: 10px; font-family: var(--disp); font-size: 64px; line-height: .9; color: var(--mode); text-shadow: 0 0 24px var(--mode); pointer-events: none; transition: color .15s; }
#modeBanner small { font-family: var(--mono); font-size: 11px; color: var(--dim); text-shadow: none; letter-spacing: 1px; }
#modeBanner .arrow { width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent; border-bottom: 30px solid var(--mode); align-self: center; filter: drop-shadow(0 0 10px var(--mode)); transition: transform .2s; }
#modeBanner.short .arrow { transform: rotate(180deg); }
#modeBanner.swap { animation: swap .35s ease-out; }
@keyframes swap { 0% { transform: translateX(-30px) skewX(-20deg); opacity: 0; } 100% { transform: none; opacity: 1; } }

#tfBar { position: absolute; top: 18px; right: 80px; z-index: 5; display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; max-width: 55%; }
#tfBar button { background: rgba(13,16,22,.85); color: var(--dim); border: 1px solid var(--line); font-size: 11px; padding: 3px 8px; border-radius: 3px; }
#tfBar button.on { color: var(--mode); border-color: var(--mode); }

#weather { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }
#entryLayer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
#entryTag { position: absolute; z-index: 4; display: none; padding: 2px 7px; border-radius: 3px; font-size: 12px; font-weight: 700;
  color: #2a0a12; background: #ffb7c5; box-shadow: 0 0 12px rgba(255,183,197,.6); pointer-events: none; }
#entryAxis { padding: 1px 0; text-align: center; font-size: 11px; font-weight: 700; color: #2a0a12; background: #ffb7c5;
  font-variant-numeric: tabular-nums; }
#entryTimer { padding: 1px 0; text-align: center; font-size: 11px; font-weight: 700; color: #ffb7c5;
  background: rgba(42,10,18,.9); border: 1px solid #ffb7c5; box-sizing: border-box; font-variant-numeric: tabular-nums; }
#barClock { position: absolute; right: 0; z-index: 4; display: none; padding: 1px 0; text-align: center; font-size: 11px; font-weight: 700; color: #000; background: var(--short); pointer-events: none; font-variant-numeric: tabular-nums; }
#barClock.up { background: var(--long); }
#barClock.soon { animation: blink .5s steps(2) infinite; }

#bigText { position: absolute; left: 0; right: 0; top: 38%; z-index: 6; text-align: center; font-family: var(--disp); font-size: 120px; letter-spacing: 4px; pointer-events: none; opacity: 0; }
#bigText.go { animation: big 1.3s cubic-bezier(.2,.9,.2,1) forwards; }
#bigText small { display: block; font-size: 38px; letter-spacing: 2px; }
@keyframes big { 0% { opacity: 0; transform: scale(2.2); filter: blur(8px); } 12% { opacity: 1; transform: scale(1); filter: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-40px) scale(.95); } }

#lockVeil { position: absolute; inset: 0; z-index: 7; display: none; align-items: center; justify-content: center; background: repeating-linear-gradient(-45deg, rgba(255,46,85,.06) 0 16px, transparent 16px 32px); backdrop-filter: grayscale(.8); }
#lockVeil.show { display: flex; }
#lockText { font-family: var(--disp); font-size: 90px; color: var(--short); text-shadow: 0 0 30px var(--short); letter-spacing: 6px; text-align: center; line-height: 1; }
#lockText small { display: block; font-family: var(--mono); font-size: 13px; letter-spacing: 1px; color: var(--text); text-shadow: none; margin-top: 10px; }

/* ---------- side ---------- */
#side { display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow-y: auto; background: var(--bg2); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.card h3 { margin: 0 0 8px; font-family: var(--disp); font-weight: normal; font-size: 16px; letter-spacing: 2px; color: var(--dim); }
.row { display: flex; justify-content: space-between; align-items: baseline; }
#posSide { font-family: var(--disp); font-size: 30px; letter-spacing: 2px; }
#posSide.long { color: var(--long); text-shadow: 0 0 12px var(--long); }
#posSide.short { color: var(--short); text-shadow: 0 0 12px var(--short); }
#posSide.flat { color: var(--dim); }
#posSize { color: var(--dim); font-size: 12px; }
.pnl { font-size: 38px; font-weight: 700; margin-top: 2px; transition: color .1s; }
.pnl.up { color: var(--long); text-shadow: 0 0 16px rgba(25,255,140,.35); }
.pnl.down { color: var(--short); text-shadow: 0 0 16px rgba(255,46,85,.35); }
.pnlpct { color: var(--dim); font-size: 12px; margin-bottom: 8px; }
.grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.grid label { color: var(--dim); font-size: 10px; letter-spacing: 1.5px; align-self: center; }
.grid span { text-align: right; }
#liq { color: var(--short); }
#blades { display: flex; gap: 5px; margin-top: 12px; }
#blades i { flex: 1; height: 12px; border: 1px solid var(--line); transform: skewX(-25deg); background: transparent; transition: background .15s, box-shadow .15s; }
#blades i.on { background: var(--mode); border-color: var(--mode); box-shadow: 0 0 10px var(--mode); }
#blades i.max { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }

/* the Sensei speaks from the bottom of the chart, like film subtitles */
#senseiCard { position: absolute; left: 16px; right: 86px; bottom: 30px; z-index: 5; margin: 0 auto; max-width: 900px;
  text-align: center; pointer-events: none; transition: opacity .8s; }
#senseiCard.quiet { opacity: .35; }
#senseiCard .mask { display: none; }
.senseiHead { display: flex; justify-content: center; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.senseiHead b { font-family: var(--disp); font-weight: normal; font-size: 14px; letter-spacing: 3px; color: #ffb7c5;
  text-shadow: 0 0 10px rgba(255, 183, 197, .6); }
.senseiHead small { color: var(--dim); font-size: 10px; }
.senseiHead .ghost { pointer-events: auto; }
.mask { width: 38px; height: 38px; flex: none; }
.mask circle:first-child { fill: #1a1f2b; stroke: var(--line); }
.mask .band { fill: #000; }
.mask .eye { fill: var(--cyan); filter: drop-shadow(0 0 3px var(--cyan)); }
#senseiCard.talking .mask .eye { animation: blink 0.4s steps(2) 3; }
#senseiLine { display: inline; margin: 0; font-size: 18px; line-height: 1.7; color: #fff; font-weight: 700;
  padding: 2px 10px; background: rgba(0, 0, 0, .55); border-radius: 3px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  text-shadow: 0 2px 3px #000, 0 0 8px #000; }
#senseiCard.fresh #senseiLine { animation: subIn .4s ease-out; }
@keyframes subIn { from { opacity: 0; transform: translateY(6px); } }
@keyframes type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

#feed { list-style: none; margin: 0; padding: 0; font-size: 12px; }
#feed li { display: grid; grid-template-columns: 60px 1fr auto; gap: 6px; padding: 5px 0; border-top: 1px solid var(--line); align-items: center; }
#feed li:first-child { border-top: 0; }
#feed .act { font-weight: 700; }
#feed .det { color: var(--dim); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#feed .st { font-size: 10px; letter-spacing: 1px; padding: 1px 5px; border-radius: 2px; }
#feed .st.sent { color: var(--gold); border: 1px solid rgba(255,194,61,.4); }
#feed .st.filled { color: #000; background: var(--long); }
#feed .st.rejected { color: #fff; background: var(--short); }
#feed .st.resting { color: var(--cyan); border: 1px solid rgba(61,224,255,.4); }
#feed li.new { animation: slidein .25s ease-out; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }
.stats span { font-size: 13px; }

/* ---------- keys ---------- */
#keys { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--bg2); }
.key { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 64px; padding: 6px 10px; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 5px; background: var(--panel); transition: transform .05s, border-color .1s, box-shadow .1s; }
.key.wide { min-width: 150px; }
.key kbd { font-size: 16px; font-weight: 700; }
.key span { font-size: 9px; letter-spacing: 1.5px; color: var(--dim); }
.key.strike { border-color: var(--mode); }
.key.strike kbd { color: var(--mode); }
.key.down { transform: translateY(2px); border-color: var(--mode); box-shadow: 0 0 16px var(--mode); }
.key.kill kbd { color: var(--short); }
.key.armed { border-color: #ffffff; box-shadow: 0 0 14px rgba(255,255,255,.5); }
.key.armed kbd { color: #ffffff; }
#killFill { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--short); box-shadow: 0 0 8px var(--short); }

/* ---------- fx ---------- */
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 20; }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 19; opacity: 0; }
#flash.go { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .32; } to { opacity: 0; } }
.shake { animation: shake .32s cubic-bezier(.36,.07,.19,.97); }
.shake-big { animation: shake .55s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 10%,90% { transform: translate(-2px,1px); } 20%,80% { transform: translate(4px,-2px); } 30%,50%,70% { transform: translate(-7px,3px); } 40%,60% { transform: translate(7px,-3px); } }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; background: rgba(4,5,8,.82); backdrop-filter: blur(4px); }
.overlay.show { display: flex; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px 28px; max-width: 560px; width: calc(100% - 32px); }
.panel h2 { font-family: var(--disp); font-weight: normal; font-size: 34px; letter-spacing: 3px; margin: 0 0 14px; color: var(--mode); }
.panel table { border-collapse: collapse; width: 100%; font-size: 13px; }
.panel td { padding: 5px 8px 5px 0; vertical-align: top; }
.panel td:first-child { white-space: nowrap; width: 90px; }
.panel kbd { display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 1px 6px; font-size: 12px; }
.fine { color: var(--dim); font-size: 11px; line-height: 1.5; }
.panel input { width: 100%; padding: 10px 12px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; font: inherit; font-size: 15px; }
.panel input:focus { outline: none; border-color: var(--mode); }
.btns { display: flex; gap: 8px; margin-top: 12px; }
.panel button:not(.ghost), #startBtn { background: var(--mode); color: #000; border: 0; border-radius: 4px; padding: 10px 18px; font-family: var(--disp); font-size: 20px; letter-spacing: 2px; }
.err { color: var(--short); font-size: 12px; min-height: 1em; margin: 8px 0 0; }

.introBox { text-align: center; padding: 16px; }
.bigStar { width: 110px; height: 110px; fill: var(--long); filter: drop-shadow(0 0 22px var(--long)); animation: spin 5s linear infinite; }
.introBox h1 { font-family: var(--disp); font-weight: normal; font-size: clamp(64px, 14vw, 150px); letter-spacing: 8px; margin: 10px 0 0; line-height: 1; }
.tag { color: var(--dim); letter-spacing: 1px; }
#startBtn { margin-top: 18px; font-size: 30px; padding: 12px 34px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 34px var(--long); } }
.introBox .fine { max-width: 460px; margin: 22px auto 0; }

@media (max-width: 900px) {
  #stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  #side { max-height: 40vh; }
  #keys { flex-wrap: wrap; }
  #app { grid-template-rows: 52px 1fr auto; }
  .topstat:nth-of-type(2) { display: none; }
  #modeBanner { font-size: 44px; }
}
