:root {
  --bg: #0b0e14;
  --panel: #12161e;
  --line: rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.14);
  --lime: #ccff00;
  --red: #ff4d4d;
  --up: #b8ff3d;
  --muted: rgba(255,255,255,.46);
  --faint: rgba(255,255,255,.28);
  --text: #f3f3f0;
  --sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; }
::selection { background: var(--lime); color: #000; }

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #0b0e14;
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 8px;
  flex: 0 0 auto;
}
.brand img { width: 22px; height: 22px; }
.brand strong {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow: auto;
}
.nav a {
  font-size: 13px;
  font-weight: 600;
  color: var(--faint);
  padding: 7px 14px;
  white-space: nowrap;
  border-radius: 999px;
}
.nav a:hover { color: #fff; }
.nav a.is-on { color: #fff; background: #1a212c; }
.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.chip {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 8px;
}
.btn-connect {
  height: 34px;
  padding: 0 14px;
  background: var(--lime);
  color: #000;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
}
.btn-connect:hover { background: #fff; }
.btn-ghost {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.btn-ghost:hover { color: #fff; border-color: var(--lime); }

.sub {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #080909;
}
.asset-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 13px;
}
.asset-pill .sym { letter-spacing: -.02em; }
.asset-pill .px {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--lime);
}
.asset-pill .chg { font-family: var(--mono); font-size: 11px; }
.chg.up { color: var(--up); }
.chg.dn { color: var(--red); }
.modes, .tfs {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}
.modes button, .tfs button {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 7px 9px;
  color: var(--faint);
  border: 1px solid transparent;
}
.modes button.is-on, .tfs button.is-on {
  color: #000;
  background: var(--lime);
}
.modes button:hover, .tfs button:hover { color: #fff; }
.timer {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--lime);
}
.timer span { color: var(--muted); font-weight: 600; margin-right: 8px; }
.quote {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.quote b { color: var(--text); font-weight: 800; margin-left: 4px; }
.quote .up { color: var(--up); }
.quote .dn { color: var(--red); }

.workspace {
  display: grid;
  grid-template-columns: 1fr 340px;
  min-height: calc(100vh - 52px - 53px - 180px);
  flex: 1;
}
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
}

.chart-wrap {
  position: relative;
  min-height: 420px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(rgba(204,255,0,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(204,255,0,.04) 1px, transparent 1px),
    #070808;
  background-size: 48px 48px, 48px 48px, auto;
}
.chart-wrap canvas { width: 100%; height: 100%; display: block; position: absolute; inset: 0; }
.chart-hint {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 2;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  pointer-events: none;
}

.panel {
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 420px;
}
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  flex: 1;
  height: 40px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 1px solid transparent;
}
.tabs button.is-on { color: var(--lime); border-bottom-color: var(--lime); }
.panel-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.field-label {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}
.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat {
  border: 1px solid var(--line);
  padding: 10px;
}
.stat b {
  display: block;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.stat span { color: var(--muted); font-size: 11px; }
.input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line-strong);
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 13px;
  background: #090a0a;
}
.input:focus { outline: 1px solid var(--lime); }
.side-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side {
  height: 40px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  border: 1px solid var(--line);
}
.side.up.is-on { background: var(--lime); color: #000; border-color: var(--lime); }
.side.dn.is-on { background: var(--red); color: #fff; border-color: var(--red); }
.btn-primary {
  height: 44px;
  width: 100%;
  background: var(--lime);
  color: #000;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.btn-primary:hover { background: #fff; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.help { font-size: 12px; color: var(--muted); line-height: 1.45; }
.book { display: flex; flex-direction: column; gap: 2px; font-family: var(--mono); font-size: 11px; }
.book-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 4px 0; }
.book-row.head { color: var(--faint); font-size: 8px; letter-spacing: .12em; text-transform: uppercase; }
.book-row .bid { color: var(--up); }
.book-row .ask { color: var(--red); }

.table-wrap {
  border-top: 1px solid var(--line);
  overflow: auto;
  max-height: 220px;
  background: #080909;
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}
.empty {
  padding: 28px 14px;
  color: var(--muted);
  font-size: 13px;
}

.page {
  padding: 28px 18px 64px;
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
}
.page h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 900;
  letter-spacing: -.06em;
  text-transform: uppercase;
  line-height: .9;
}
.lede { margin: 12px 0 28px; max-width: 640px; color: var(--muted); line-height: 1.55; }
.kicker {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--lime);
  margin-bottom: 10px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }
.card {
  border: 1px solid var(--line);
  padding: 18px;
  background: var(--panel);
}
.card h2 { font-size: 14px; font-weight: 800; margin-bottom: 8px; }
.card p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.big { font-size: 28px; font-weight: 900; letter-spacing: -.04em; color: var(--lime); }
.list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.list li { list-style: none; padding-left: 14px; border-left: 1px solid var(--lime); color: var(--muted); font-size: 13px; line-height: 1.45; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 16px;
}
.modal.open { display: flex; }
.modal-card {
  width: min(420px, 100%);
  background: #0c0d0d;
  border: 1px solid var(--line-strong);
  padding: 22px;
}
.modal-card h2 { font-size: 18px; font-weight: 900; letter-spacing: -.03em; margin-bottom: 8px; }
.modal-card p { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 16px; }
.opt {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  padding: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}
.opt:hover { border-color: var(--lime); }
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  background: var(--lime);
  color: #000;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 10px 12px;
  display: none;
}

.play-field {
  position: relative;
  height: min(64vh, 640px);
  border: 1px solid var(--line);
  background: #050606;
  overflow: hidden;
}
.play-field canvas { width: 100%; height: 100%; display: block; }
.play-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
@media (max-width: 720px) { .play-hud { grid-template-columns: 1fr 1fr; } }

.lev {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lev input { flex: 1; accent-color: var(--lime); }

.status-ok { color: var(--lime); }
.status-bad { color: var(--red); }

.arena {
  position: relative;
  height: calc(100vh - 56px);
  background: #0b0e14;
  overflow: hidden;
}
.arena-stage { position: absolute; inset: 0; }
.arena-stage canvas { width: 100%; height: 100%; display: block; }
.cells {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.gcell {
  position: absolute;
  pointer-events: auto;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 8px 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.gcell.up { background: rgba(74, 98, 18, .55); }
.gcell.dn { background: rgba(92, 32, 38, .55); }
.gcell.empty { background: transparent; pointer-events: none; }
.gcell.is-on { outline: 1px solid #ccff00; }
.gcell strong { font-size: 15px; font-weight: 700; color: #e8f5a0; }
.gcell.dn strong { color: #ffb4b8; }
.gcell span { font-size: 11px; color: rgba(255,255,255,.55); }
.gcell.up span { color: #c6e06a; }
.gcell.dn span { color: #e0898f; }

.arena-hud {
  position: absolute;
  left: 16px;
  top: 14px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(640px, 72vw);
}
.hud-card {
  background: rgba(16, 20, 28, .86);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 10px 12px;
  backdrop-filter: blur(16px);
}
.hud-top { display: flex; align-items: center; gap: 12px; }
.asset-dd {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a212c;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
}
.hud-px { font-size: 18px; font-weight: 800; letter-spacing: -.03em; }
.hud-time { font-size: 12px; color: var(--muted); }
.hud-card .modes { margin-top: 8px; }
.hud-card .modes button {
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
  padding: 6px 10px;
}
.hud-card .modes button.is-on { background: #fff; color: #000; }
.tfs-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
.tfs-row button {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.tfs-row button.is-on { background: #fff; color: #000; }

.trade-pop {
  position: absolute;
  z-index: 8;
  width: 240px;
  background: #12161e;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
}
.trade-pop[hidden] { display: none; }
.trade-pop .field-label { margin-top: 8px; }
.trade-pop .btn-primary { margin-top: 10px; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
