:root {
  --bg: #090806;
  --parchment: #d9c79f;
  --muted: #8f8879;
  --buy: #42d17a;
  --buy-dark: #143b24;
  --sell: #ef5a58;
  --sell-dark: #4d1c1b;
  --gold: #c5a35a;
  --panel: rgba(14, 13, 11, 0.74);
  --border: rgba(217, 199, 159, 0.17);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
body { font-family: Inter, system-ui, -apple-system, sans-serif; color: #f5f0e7; }
button { font: inherit; }

.app-shell { position: relative; width: 100%; height: 100%; min-height: 620px; background: #0a0907; }
#battlefield { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.glass {
  background: linear-gradient(180deg, rgba(24, 22, 18, .84), rgba(10, 9, 8, .78));
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0,0,0,.28), inset 0 1px rgba(255,255,255,.025);
  backdrop-filter: blur(14px);
}

.topbar {
  position: absolute; z-index: 10; left: 18px; right: 18px; top: 16px;
  height: 78px; border-radius: 12px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 20px;
}
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border: 1px solid rgba(197,163,90,.55); border-radius: 50%; display: grid; place-items: center; color: var(--gold); font: 700 24px/1 Cinzel, serif; box-shadow: inset 0 0 20px rgba(197,163,90,.08); }
.brand { font: 700 17px/1.1 Cinzel, serif; letter-spacing: .12em; }
.tagline { margin-top: 5px; font-size: 9px; letter-spacing: .25em; color: var(--muted); }
.price-block { text-align: center; min-width: 260px; }
.pair { font: 600 9px Cinzel, serif; letter-spacing: .2em; color: var(--gold); }
.price { margin-top: 2px; font: 700 28px/1 Cinzel, serif; letter-spacing: .03em; }
.spread { margin-top: 5px; font-size: 10px; color: #9a9489; }
.status-block { justify-self: end; text-align: right; }
.status-line { display: flex; justify-content: flex-end; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #d8a245; box-shadow: 0 0 12px currentColor; }
.status-dot.live { background: var(--buy); }
.status-dot.error { background: var(--sell); }
.source { margin-top: 5px; font-size: 8px; letter-spacing: .14em; color: var(--muted); }

.side-panel { position: absolute; z-index: 6; top: 112px; width: 190px; padding: 14px 15px; border-radius: 10px; }
.buy-panel { left: 18px; }
.sell-panel { right: 18px; text-align: right; }
.faction-title { font: 700 11px Cinzel, serif; letter-spacing: .17em; }
.faction-title.buy { color: var(--buy); }
.faction-title.sell { color: var(--sell); }
.metric-label { margin-top: 12px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.metric-value { margin-top: 3px; font: 600 19px Cinzel, serif; }
.metric-sub { margin-top: 3px; font-size: 8px; color: #777166; }

.center-banner { position: absolute; z-index: 5; top: 108px; left: 50%; transform: translateX(-50%); width: 150px; text-align: center; pointer-events: none; }
.center-rule { height: 22px; width: 1px; margin: 0 auto; background: linear-gradient(var(--gold), transparent); opacity: .7; }
.center-label { font: 700 9px Cinzel, serif; letter-spacing: .2em; color: var(--gold); }
.center-price { margin-top: 4px; font: 600 11px Cinzel, serif; color: #ddd4c2; }

.controls { position: absolute; z-index: 10; left: 50%; bottom: 20px; transform: translateX(-50%); min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 12px; }
.control-group { display: flex; align-items: center; gap: 5px; }
.control-label { padding: 0 7px; font: 600 8px Cinzel, serif; letter-spacing: .16em; color: var(--muted); }
.range-btn, .mode-btn, .icon-btn, .legend-toggle { border: 1px solid rgba(255,255,255,.075); background: rgba(255,255,255,.035); color: #bdb6a9; cursor: pointer; transition: .18s ease; }
.range-btn { height: 31px; padding: 0 9px; border-radius: 7px; font-size: 9px; }
.range-btn:hover, .range-btn.active { color: #f4ead5; border-color: rgba(197,163,90,.45); background: rgba(197,163,90,.11); }
.mode-btn { height: 31px; min-width: 66px; border-radius: 7px; font: 700 9px Cinzel, serif; letter-spacing: .13em; color: var(--buy); }
.mode-btn.sim { color: #e4b65a; }
.icon-btn { height: 31px; width: 34px; border-radius: 7px; font-size: 12px; }
.divider { width: 1px; height: 22px; background: rgba(255,255,255,.08); }

.legend { position: absolute; z-index: 10; right: 18px; bottom: 82px; width: 225px; border-radius: 10px; overflow: hidden; }
.legend-toggle { width: 100%; height: 36px; border: 0; border-bottom: 1px solid transparent; text-align: left; padding: 0 12px; font: 700 9px Cinzel, serif; letter-spacing: .12em; }
.legend.open .legend-toggle { border-bottom-color: var(--border); color: var(--gold); }
.legend-body { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.legend.open .legend-body { max-height: 360px; }
.legend-row { height: 29px; display: grid; grid-template-columns: 20px 1fr auto; align-items: center; padding: 0 10px; border-top: 1px solid rgba(255,255,255,.025); font-size: 9px; }
.legend-row span { color: var(--gold); }
.legend-row b { font-weight: 500; }
.legend-row em { font-style: normal; color: var(--muted); font-size: 8px; }

.battle-log { position: absolute; z-index: 8; left: 18px; bottom: 82px; width: 245px; border-radius: 10px; overflow: hidden; }
.log-title { height: 34px; display: flex; align-items: center; padding: 0 12px; border-bottom: 1px solid var(--border); font: 700 9px Cinzel, serif; letter-spacing: .13em; color: var(--gold); }
.log-items { max-height: 118px; overflow: hidden; }
.log-row, .log-empty { height: 28px; display: grid; grid-template-columns: 48px 1fr 64px; align-items: center; padding: 0 10px; font-size: 8px; border-top: 1px solid rgba(255,255,255,.025); }
.log-empty { display: flex; color: var(--muted); }
.log-row .buy { color: var(--buy); font-weight: 700; }
.log-row .sell { color: var(--sell); font-weight: 700; }
.log-row .qty { text-align: right; color: #aaa397; }

.tooltip { position: absolute; z-index: 20; width: 218px; padding: 12px; border-radius: 9px; pointer-events: none; }
.tooltip .tt-side { font: 700 9px Cinzel, serif; letter-spacing: .16em; }
.tooltip .tt-name { margin-top: 6px; font: 700 15px Cinzel, serif; }
.tooltip .tt-grid { margin-top: 10px; display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 9px; }
.tooltip .tt-grid span:nth-child(odd) { color: var(--muted); }
.tooltip .tt-grid span:nth-child(even) { text-align: right; }

.footer-note { position: absolute; z-index: 5; left: 50%; bottom: 4px; transform: translateX(-50%); font-size: 7px; letter-spacing: .08em; color: rgba(180,173,160,.46); }

@media (max-width: 900px) {
  .topbar { height: 68px; padding: 0 12px; }
  .brand-mark { display: none; }
  .tagline, .source { display: none; }
  .price-block { min-width: 160px; }
  .price { font-size: 21px; }
  .side-panel { top: 96px; width: 148px; }
  .metric-sub { display: none; }
  .battle-log { display: none; }
  .legend { width: 184px; }
  .controls { bottom: 15px; width: calc(100% - 20px); overflow-x: auto; justify-content: center; }
  .control-label { display: none; }
  .range-btn { padding: 0 7px; }
}
