/* Fake stock exchange screen — xscript.net */

:root {
  --bg: #03070d;
  --panel: rgba(8, 18, 30, 0.92);
  --panel-head: rgba(14, 30, 48, 0.95);
  --line: #13324d;
  --line-bright: #1f5a85;
  --text: #c9d6e3;
  --muted: #5f7a93;
  --accent: #00d4ff;
  --accent-2: #ffb300;
  --up: #00e676;
  --down: #ff3d57;
  --up-bg: rgba(0, 230, 118, 0.22);
  --down-bg: rgba(255, 61, 87, 0.22);
  --flat: #8aa0b4;
  --font-data: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-brand: 'Orbitron', var(--font-data);
}

:root[data-theme="amber"] {
  --bg: #050300;
  --panel: rgba(18, 11, 0, 0.94);
  --panel-head: rgba(34, 21, 0, 0.96);
  --line: #3a2600;
  --line-bright: #6b4700;
  --text: #ffcf70;
  --muted: #9a7330;
  --accent: #ffb000;
  --accent-2: #ffe28a;
  --up: #ffe14d;
  --down: #ff6a1f;
  --up-bg: rgba(255, 225, 77, 0.22);
  --down-bg: rgba(255, 106, 31, 0.24);
  --flat: #c79a45;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { background: var(--bg); }

body {
  font-family: var(--font-data);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
}

button, select { font-family: inherit; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }

/* ---------- App shell ---------- */
.exchange {
  height: 100vh;
  min-height: 640px;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(0, 212, 255, 0.08), transparent 60%),
    var(--bg);
  position: relative;
}

:root[data-theme="amber"] .exchange {
  background:
    radial-gradient(ellipse at 50% -20%, rgba(255, 176, 0, 0.08), transparent 60%),
    var(--bg);
}

.exchange:fullscreen { height: 100vh; width: 100vw; min-height: 0; }
.exchange:-webkit-full-screen { height: 100vh; width: 100vw; min-height: 0; }

/* ---------- Header ---------- */
.xh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--panel-head);
  border-bottom: 1px solid var(--line-bright);
  flex: 0 0 auto;
}

.xh-left, .xh-right { display: flex; align-items: center; gap: 12px; }
.xh-right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.xh-logo { font-size: 1.5rem; color: var(--accent-2); line-height: 1; }

.xh-name { display: flex; flex-direction: column; line-height: 1.05; }
.xh-title {
  font-family: var(--font-brand);
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.18em;
  color: var(--accent);
}
.xh-sub { font-size: 0.6rem; letter-spacing: 0.22em; color: var(--muted); }

.xh-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--up);
  border: 1px solid currentColor;
  padding: 3px 8px;
  border-radius: 2px;
}
.xh-status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}
.xh-status.is-halted { color: var(--down); }
.xh-status.is-paused { color: var(--accent-2); }
.xh-status.is-paused .dot { animation: none; }

.xh-sim {
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  color: var(--muted);
  border: 1px dashed var(--line-bright);
  padding: 3px 6px;
}

.xh-clock {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.xh-mood {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.xh-mood select {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--line-bright);
  padding: 5px 6px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.xbtn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line-bright);
  padding: 6px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.xbtn:hover, .xbtn:focus-visible { background: rgba(0, 212, 255, 0.12); border-color: var(--accent); }
:root[data-theme="amber"] .xbtn:hover, :root[data-theme="amber"] .xbtn:focus-visible { background: rgba(255, 176, 0, 0.12); }
.xbtn[aria-pressed="true"] { color: var(--accent-2); border-color: var(--accent-2); }

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- Ticker tape ---------- */
.tape {
  flex: 0 0 auto;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.55);
  height: 30px;
  display: flex;
  align-items: center;
}

.tape-track {
  display: flex;
  width: max-content;
  animation: tape 90s linear infinite;
}
.tape-track.is-paused { animation-play-state: paused; }

.tape-group { display: flex; }

.tape-item {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
  padding: 0 22px;
  font-size: 0.82rem;
  white-space: nowrap;
  border-right: 1px solid var(--line);
}
.tape-item .t-sym { color: var(--accent-2); font-weight: 700; }
.tape-item .t-px { color: var(--text); }

@keyframes tape {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ---------- Indices ---------- */
.indices {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px 10px 0;
}

.idx {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 7px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  min-width: 0;
}
.idx-name { font-size: 0.66rem; letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idx-val { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.idx-chg { font-size: 0.76rem; font-weight: 600; white-space: nowrap; }
.idx-spark { grid-row: 1 / span 2; grid-column: 2; width: 110px; height: 38px; }
.idx-main { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; min-width: 0; }

/* ---------- Main grid ---------- */
.xgrid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(330px, 1.1fr) minmax(0, 1.6fr) minmax(250px, 0.8fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 0.42fr);
  grid-template-areas:
    "board chart book"
    "heat  news  tape";
  gap: 8px;
  padding: 8px 10px;
  position: relative;
}

.p-board { grid-area: board; }
.p-chart { grid-area: chart; }
.p-book  { grid-area: book; }
.p-heat  { grid-area: heat; }
.p-news  { grid-area: news; }
.p-tape  { grid-area: tape; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.ph {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-head);
  flex: 0 0 auto;
  white-space: nowrap;
  overflow: hidden;
}
.ph-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em; color: var(--accent); }
.ph-note { margin-left: auto; font-size: 0.6rem; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }

.pb { flex: 1 1 auto; min-height: 0; overflow: hidden; position: relative; }

/* ---------- Market board ---------- */
.board-wrap { overflow-y: auto; }

.board { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.board th {
  position: sticky;
  top: 0;
  background: var(--panel-head);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-align: right;
  padding: 5px 6px;
  border-bottom: 1px solid var(--line);
}
.board th:first-child, .board td:first-child,
.board th.c-name, .board td.c-name { text-align: left; }

.board td {
  padding: 4px 6px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}
.board td:first-child { color: var(--accent-2); font-weight: 700; }
.board td.c-name { color: var(--muted); max-width: 112px; overflow: hidden; text-overflow: ellipsis; font-size: 0.7rem; }
.board td.c-last { color: var(--text); font-weight: 600; }
.board td.c-vol { color: var(--muted); }

.board tbody tr { cursor: pointer; }
.board tbody tr:hover td { background: rgba(255, 255, 255, 0.04); }
.board tbody tr.is-selected td { background: rgba(0, 212, 255, 0.1); }
:root[data-theme="amber"] .board tbody tr.is-selected td { background: rgba(255, 176, 0, 0.12); }
.board tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.flash-up { animation: flashUp 0.7s ease-out; }
.flash-down { animation: flashDown 0.7s ease-out; }
@keyframes flashUp { from { background: var(--up-bg); } to { background: transparent; } }
@keyframes flashDown { from { background: var(--down-bg); } to { background: transparent; } }

/* ---------- Chart ---------- */
.chart-head { gap: 12px; }
.chart-head .ph-title { font-size: 0.9rem; color: var(--accent-2); }
.chart-name { font-size: 0.7rem; color: var(--muted); flex-shrink: 0; }
.chart-last { font-size: 1rem; font-weight: 700; color: var(--text); }
.chart-chg { font-size: 0.78rem; font-weight: 600; }
.chart-ohlc { font-size: 0.66rem; color: var(--muted); letter-spacing: 0.04em; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.chart-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- Order book ---------- */
.book { display: flex; flex-direction: column; font-size: 0.78rem; }
.book-cols, .book-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  padding: 0 8px;
}
.book-cols {
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding-top: 5px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.book-cols span:nth-of-type(1), .book-row span:nth-of-type(1) { text-align: left; }
.book-cols span:nth-of-type(2), .book-row span:nth-of-type(2) { text-align: right; padding-right: 10px; }
.book-cols span:nth-of-type(3), .book-row span:nth-of-type(3) { text-align: left; padding-left: 10px; }
.book-cols span:nth-of-type(4), .book-row span:nth-of-type(4) { text-align: right; }

.book-rows { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.book-row {
  flex: 1 1 0;
  min-height: 15px;
  max-height: 26px;
  align-items: center;
  position: relative;
}
.book-row span { position: relative; z-index: 1; }
.book-row .b-px { color: var(--up); font-weight: 600; }
.book-row .a-px { color: var(--down); font-weight: 600; }
.book-row .sz { color: var(--text); }
.book-row.is-best { background: rgba(255, 255, 255, 0.04); }

.depth {
  position: absolute;
  top: 1px;
  bottom: 1px;
  opacity: 0.18;
  z-index: 0;
}
.depth.bid { right: 50%; background: var(--up); }
.depth.ask { left: 50%; background: var(--down); }

.book-spread {
  flex: 0 0 auto;
  text-align: center;
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  padding: 5px;
  border-top: 1px solid var(--line);
}

/* ---------- Heatmap ---------- */
.heat {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 3px;
  padding: 6px;
}
.heat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  font-size: 0.7rem;
  line-height: 1.2;
  color: #fff;
  background: #2a3642;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.6s;
}
.heat-tile b { font-size: 0.74rem; letter-spacing: 0.04em; }
.heat-tile.is-selected { border-color: var(--accent); }
:root[data-theme="amber"] .heat-tile { color: #1a0f00; }

/* ---------- News ---------- */
.news { overflow: hidden; padding: 2px 0; }
.news-item {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 4px 10px;
  font-size: 0.74rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  white-space: nowrap;
}
.news-item .n-time { color: var(--muted); font-size: 0.66rem; }
.news-item .n-tag {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--bg);
  background: var(--accent);
  padding: 1px 5px;
}
.news-item .n-tag.t-alert { background: var(--down); color: #fff; }
.news-item .n-tag.t-earn { background: var(--accent-2); }
.news-item .n-text { overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.news-item.is-new { animation: newsIn 0.5s ease-out; }
@keyframes newsIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Time & sales ---------- */
.ts { display: flex; flex-direction: column; font-size: 0.76rem; }
.ts-cols, .ts-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  padding: 2px 10px;
}
.ts-cols {
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding-top: 5px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.ts-cols span:not(:first-child), .ts-row span:not(:first-child) { text-align: right; }
.ts-rows { flex: 1 1 auto; overflow: hidden; }
.ts-row .ts-time { color: var(--muted); }
.ts-row.is-block { background: rgba(255, 255, 255, 0.06); font-weight: 700; }
.ts-row.is-block .ts-size::after { content: ' BLK'; font-size: 0.56rem; color: var(--accent-2); }

/* ---------- Halt overlay ---------- */
.halt {
  position: absolute;
  inset: 8px 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 0, 4, 0.72);
  backdrop-filter: blur(2px);
}
.halt[hidden] { display: none; }
.halt-box {
  text-align: center;
  border: 2px solid var(--down);
  background: rgba(20, 0, 6, 0.92);
  padding: 26px 40px;
  box-shadow: 0 0 40px rgba(255, 61, 87, 0.35);
  max-width: 92%;
}
.halt-kicker { font-size: 0.75rem; letter-spacing: 0.3em; color: var(--down); font-weight: 700; }
.halt-title {
  font-family: var(--font-brand);
  font-size: clamp(1.4rem, 3.2vw, 2.6rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  margin: 10px 0;
  animation: haltBlink 2s ease-in-out infinite;
}
.halt-detail { font-size: 0.85rem; color: var(--text); letter-spacing: 0.08em; }
.halt-count { margin-top: 14px; font-size: 1.1rem; font-weight: 700; color: var(--down); letter-spacing: 0.1em; }
.halt-reset { margin-top: 18px; font-size: 0.85rem; padding: 10px 18px; }
@keyframes haltBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- Bottom bar ---------- */
.xb {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 14px;
  border-top: 1px solid var(--line-bright);
  background: var(--panel-head);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.xb-item b { color: var(--text); font-weight: 600; margin-left: 4px; letter-spacing: 0.04em; }
.xb-breadth { display: inline-flex; align-items: center; gap: 6px; }
.xb-breadth b { margin: 0; }
.breadth {
  display: inline-block;
  width: 120px;
  height: 7px;
  background: var(--down);
  opacity: 0.85;
}
.breadth-fill { display: block; height: 100%; width: 50%; background: var(--up); transition: width 0.6s; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Reference content ---------- */
.tool-info {
  max-width: 900px;
  margin: 44px auto 40px;
  padding: 0 24px;
  color: #8197ab;
  line-height: 1.7;
  font-size: 0.92rem;
}
:root[data-theme="amber"] .tool-info { color: #b58e4a; }
.tool-info h1 {
  color: var(--accent);
  font-size: 1.3rem;
  letter-spacing: 0.03em;
  margin-bottom: 14px;
  line-height: 1.35;
}
.tool-info h2 {
  color: var(--accent);
  font-size: 1.02rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 30px 0 10px;
}
.tool-info h3 { color: var(--accent); font-size: 0.94rem; margin: 22px 0 6px; }
.tool-info p { margin-bottom: 12px; }
.tool-info ul { margin: 0 0 12px 22px; }
.tool-info li { margin-bottom: 6px; }
.tool-info a { color: var(--accent); }
.tool-info strong { color: #e8eaed; }
:root[data-theme="amber"] .tool-info strong { color: #ffe2a6; }
.tool-info kbd {
  font-family: var(--font-data);
  font-size: 0.8em;
  border: 1px solid var(--line-bright);
  border-bottom-width: 2px;
  padding: 0 5px;
  border-radius: 3px;
  color: var(--text);
}
.glossary { margin: 0 0 12px; }
.glossary dt {
  color: var(--accent-2);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.84rem;
  margin-top: 16px;
}
.glossary dd { margin: 4px 0 0; }

.site-foot {
  border-top: 1px solid var(--line-bright);
  background: var(--panel-head);
  padding: 15px;
  text-align: center;
  font-size: 0.8rem;
}
.site-foot-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.site-foot-links a { color: var(--accent); text-decoration: none; }
.site-foot-links a:hover { text-decoration: underline; }
.site-foot-note { color: var(--muted); font-size: 0.72rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1450px) {
  .c-name { display: none; }
}

@media (max-width: 1280px) {
  .idx-spark { width: 80px; }
  .xh-sub, .xh-sim { display: none; }
}

@media (max-width: 1050px) {
  .exchange { height: auto; min-height: 0; }
  .indices { grid-template-columns: repeat(2, 1fr); }
  .xgrid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 360px 380px 260px 220px;
    grid-template-areas:
      "chart chart"
      "board book"
      "heat  tape"
      "news  news";
  }
  .xh { flex-wrap: wrap; }
  .xh-center { order: 3; width: 100%; text-align: center; display: none; }
}

@media (max-width: 640px) {
  .xh-left { flex-wrap: wrap; }
  .xh-right { justify-content: flex-start; }
  .indices { grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px 6px 0; }
  .idx-spark { display: none; }
  .idx { grid-template-columns: 1fr; }
  .idx-val { font-size: 1rem; }
  .xgrid {
    grid-template-columns: 1fr;
    grid-template-rows: 300px 420px 300px 240px 260px 220px;
    grid-template-areas: "chart" "board" "book" "tape" "heat" "news";
    padding: 6px;
    gap: 6px;
  }
  .c-vol { display: none; }
  .chart-ohlc, .chart-name { display: none; }
  .xb { flex-wrap: wrap; justify-content: center; gap: 8px 14px; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .tape-track { animation-duration: 240s; }
  .flash-up, .flash-down, .news-item.is-new { animation: none; }
  .xh-status .dot, .halt-title { animation: none; }
  .heat-tile, .breadth-fill { transition: none; }
}
