/* QuantFly dark theme: canvas on the left, HUD on the right, stacked under 560px. */
:root {
  --bg: #0a0c10;
  --panel: #12161d;
  --panel-edge: #1e2530;
  --ink: #d7dee8;
  --muted: #7c8798;
  --call: #3ad06a;
  --put: #ff4d4d;
  --flat: #8a8f98;
  --up: #3ad06a;
  --down: #ff4d4d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 13px/1.4 "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

#viewport {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

#viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hud {
  flex: 0 0 280px;
  width: 280px;
  padding: 10px;
  overflow-y: auto;
  border-left: 1px solid var(--panel-edge);
  background: var(--bg);
}

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
}

.row > span:first-child {
  color: var(--muted);
}

.head {
  font-size: 15px;
  padding-bottom: 8px;
}

#ticker {
  font-weight: 700;
  letter-spacing: 0.08em;
}

#spot {
  font-variant-numeric: tabular-nums;
}

/* Sound toggle sits beside the ticker; margin-right keeps the spot pinned to the edge. */
#sound-toggle {
  margin-right: auto;
  font-size: 13px;
  line-height: 1;
}

.rows {
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--panel-edge);
}

.pnl-up {
  color: var(--up);
}

.pnl-down {
  color: var(--down);
}

/* Keep the LEARNED badge beside the P&L value inside the row's right-hand cell. */
.pnl-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#learned {
  background: #10331f;
  color: var(--up);
}

/* The trainer summary can be long; let it wrap against the right edge. */
#training {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.panel {
  padding: 10px 0;
  border-bottom: 1px solid var(--panel-edge);
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.muted {
  float: right;
  color: var(--muted);
  font-weight: 400;
}

#rates .rate {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-variant-numeric: tabular-nums;
}

#rates .rate span:first-child {
  color: var(--muted);
}

.eyes {
  display: flex;
  gap: 8px;
}

.eyes figure {
  flex: 1 1 0;
  margin: 0;
}

.eyes canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  background: #000;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.eyes figcaption {
  margin-top: 3px;
  font-size: 10px;
  color: var(--muted);
}

#spark {
  width: 100%;
  height: auto;
  display: block;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
}

/* Nicotine row: label, dose meter, smoking badge, and the light-one button. */
.dose {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dose > span:first-child {
  color: var(--muted);
}

.meter {
  flex: 1 1 auto;
  height: 6px;
  background: #0a0c10;
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  overflow: hidden;
}

.meter > span {
  display: block;
  width: 0;
  height: 100%;
  background: #d4a017;
  transition: width 150ms linear;
}

.badge {
  padding: 1px 5px;
  border-radius: 3px;
  background: #4a2410;
  color: #ffb56b;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chip,
.brain-expand {
  padding: 1px 6px;
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}

.chip:hover,
.brain-expand:hover {
  border-color: var(--muted);
}

/* Brain window: 300x240 canvas; its wrapper can cover the whole viewport. */
#brain-wrap {
  position: relative;
  background: #000;
  border: 1px solid var(--panel-edge);
  border-radius: 4px;
  overflow: hidden;
}

#brain-window {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 4;
  background: #000;
}

#brain-wrap.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  border: none;
  border-radius: 0;
}

#brain-wrap.fullscreen #brain-window {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
}

.brain-expand {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  background: rgba(10, 12, 16, 0.7);
}

.brain-modes {
  float: right;
  display: inline-flex;
  gap: 4px;
}

/* At phone width the HUD drops below the canvas and scrolls. */
@media (max-width: 560px) {
  #app {
    flex-direction: column;
  }

  #viewport {
    flex: 1 1 50vh;
  }

  #hud {
    flex: 1 1 auto;
    width: auto;
    border-left: none;
    border-top: 1px solid var(--panel-edge);
  }
}
