:root {
  --bg: #0a0a0a;
  --bg-2: #11161c;
  --fg: #ffffff;
  --accent: #f5a623;
  --accent-2: #ffcc66;
  --up: #00d68f;
  --up-bright: #5cffb6;
  --down: #ff3d3d;
  --down-bright: #ff7b7b;
  --muted: #555;
  --divider: #222;
  --grid: rgba(255, 255, 255, 0.025);
  --speed: 60s;
  --speed-indices: 90s;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 100% 32px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 32px 100%,
    radial-gradient(ellipse at top, #11161c 0%, var(--bg) 60%);
  color: var(--fg);
  font-family: 'JetBrains Mono', 'Roboto Mono', ui-monospace, Menlo, Consolas, monospace;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ───────────────────────── Top bar ───────────────────────── */

.topbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1.5rem;
  padding: 0.55rem 1.25rem;
  background: linear-gradient(180deg, #0e1318 0%, #0a0a0a 100%);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 0 24px rgba(245, 166, 35, 0.12);
  font-size: clamp(0.9rem, 1.7vh, 1.1rem);
  letter-spacing: 0.04em;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--accent);
  font-weight: 800;
  text-shadow: 0 0 10px rgba(245, 166, 35, 0.35);
}
.brand-mark {
  display: inline-block;
  font-size: 1.2em;
  animation: pulse-mark 2.4s ease-in-out infinite;
}
@keyframes pulse-mark {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.92); }
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.1rem;
  color: var(--fg);
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #fff;
}
.live .dot {
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: var(--down);
  box-shadow: 0 0 10px var(--down);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.85); }
}

.market-status {
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.15rem 0.55rem;
  border-radius: 4px;
  border: 1px solid var(--muted);
}
.market-status[data-status="market-open"]  { color: #001a10; background: var(--up);     border-color: var(--up);     }
.market-status[data-status="pre-market"]   { color: #1a1500; background: var(--accent); border-color: var(--accent); }
.market-status[data-status="after-hours"]  { color: #1a1500; background: var(--accent); border-color: var(--accent); }
.market-status[data-status="closed"]       { color: var(--muted); background: transparent; border-color: var(--muted); }

.clock {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.date {
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* ───────────────────────── Ticker tape (3 rows) ───────────────────────── */

.ticker-tape {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.row {
  display: flex;
  align-items: center;
  overflow: hidden;
  position: relative;
}

/* Indices row: smaller, distinct background (slightly lifted), border below.
   Sits at the top, scrolls left. */
.row-indices {
  flex: 0 0 auto;
  height: clamp(3rem, 8vh, 4.5rem);
  background: linear-gradient(180deg, #0d1218 0%, #090c10 100%);
  border-bottom: 1px solid var(--divider);
}
.row-indices .track {
  font-size: clamp(1.4rem, 3.2vh, 2.4rem);
  gap: 1rem;
}
.row-indices .track-left  { animation: scroll-left  var(--speed-indices) linear infinite; }
.row-indices .track-right { animation: scroll-right var(--speed-indices) linear infinite; }

/* Two big rows below split the rest of the viewport in half. */
.row-top, .row-bottom { flex: 1 1 50%; }
.row-bottom { border-top: 1px solid var(--divider); }

.track {
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  font-size: clamp(2.75rem, 6.5vh, 5.25rem);
  gap: 1.5rem;
  will-change: transform;
}

.track-left  { animation: scroll-left  var(--speed) linear infinite; }
.track-right { animation: scroll-right var(--speed) linear infinite; }

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

.cell {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0 0.5rem;
  transition: background-color 400ms ease-out;
  border-radius: 4px;
}

.sym {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 0 8px rgba(245, 166, 35, 0.35);
}

/* Indices row: the "symbol" slot is actually a localized label
   (DOW, NIKKEI, IPSA…) — render in cooler color so it reads as
   index name rather than ticker. */
.row-indices .sym {
  color: var(--accent-2);
  font-weight: 800;
}

.price {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.18);
}

/* ── Change colors by direction + magnitude ──
   .up / .down: <1% small move
   .mid: 1–3%
   .strong: 3–5%
   .mega: >=5%
*/
.chg            { font-variant-numeric: tabular-nums; }
.chg.flat       { color: var(--muted); }

.chg.up         { color: var(--up); }
.chg.up.mid     { color: var(--up); text-shadow: 0 0 6px rgba(0, 214, 143, 0.35); }
.chg.up.strong  { color: var(--up-bright); font-weight: 700; text-shadow: 0 0 10px rgba(0, 214, 143, 0.65); }
.chg.up.mega    { color: var(--up-bright); font-weight: 800; text-shadow: 0 0 16px rgba(0, 214, 143, 0.95), 0 0 4px #fff; }

.chg.down       { color: var(--down); }
.chg.down.mid   { color: var(--down); text-shadow: 0 0 6px rgba(255, 61, 61, 0.35); }
.chg.down.strong{ color: var(--down-bright); font-weight: 700; text-shadow: 0 0 10px rgba(255, 61, 61, 0.65); }
.chg.down.mega  { color: var(--down-bright); font-weight: 800; text-shadow: 0 0 16px rgba(255, 61, 61, 0.95), 0 0 4px #fff; }

.cell.mega .sym { font-weight: 900; text-shadow: 0 0 14px rgba(245, 166, 35, 0.7); }

.sep {
  color: var(--muted);
  user-select: none;
}

.cell.flash-up   { background-color: rgba(0, 214, 143, 0.20); }
.cell.flash-down { background-color: rgba(255, 61, 61, 0.20); }

/* ───────────────────────── Responsive squeeze ───────────────────────── */

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr; gap: 0.5rem; padding: 0.5rem 0.75rem; }
  .status { justify-content: space-between; flex-wrap: wrap; }
  .row-indices { height: clamp(2.4rem, 7vh, 3.5rem); }
  .row-indices .track { font-size: clamp(1.1rem, 2.6vh, 1.8rem); }
}
