:root {
  --bg: #071019;
  --panel: #0d1824;
  --panel-2: #111f2d;
  --line: #223449;
  --text: #f4f8fb;
  --muted: #8fa3b6;
  --accent: #ff4b6e;
  --accent-2: #ff8ca2;
  --even: #33d0aa;
  --odd: #f2aa4c;
  --warn: #f1c75b;
  --danger: #ff6b6b;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(255,75,110,.11), transparent 30%),
    radial-gradient(circle at 90% 5%, rgba(51,208,170,.09), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }

.app-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .15em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 4vw, 48px); line-height: 1.02; }
h2 { margin-bottom: 0; font-size: clamp(19px, 2.3vw, 26px); }
.subhead { color: var(--muted); max-width: 840px; margin-bottom: 0; line-height: 1.6; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }

.card,
.metric-card {
  background: linear-gradient(180deg, rgba(17,31,45,.98), rgba(11,24,35,.98));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.card { padding: 22px; }

.status-stack { text-align: right; min-width: 180px; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  font-weight: 800;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 5px rgba(255,107,107,.10); }
.status-badge.online .status-dot { background: var(--even); box-shadow: 0 0 0 5px rgba(51,208,170,.10); }
.status-badge.connecting .status-dot { background: var(--warn); box-shadow: 0 0 0 5px rgba(241,199,91,.10); }
#marketStatus { margin-top: 8px; }

.control-card { margin-bottom: 18px; }
.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
label span { display: block; margin: 0 0 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
label span b { font-weight: 700; color: #c7d2dc; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #08131e;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,75,110,.12); }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 850;
  color: var(--text);
  background: #162536;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: transparent; }
.btn.secondary { background: #213246; }
.btn.ghost { background: transparent; }
.tiny-btn { padding: 7px 10px; font-size: 12px; }
.api-note { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.market-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric-card { padding: 17px; min-height: 116px; }
.metric-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; margin-bottom: 8px; }
.metric-card strong { display: block; font-size: clamp(24px, 3vw, 34px); }
.metric-card small { display: block; margin-top: 5px; color: var(--muted); }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.digit-card { margin-bottom: 18px; overflow: hidden; }
.digit-rail-wrap { position: relative; padding-top: 36px; }
.digit-rail {
  display: grid;
  grid-template-columns: repeat(10, minmax(56px, 1fr));
  gap: 12px;
  min-width: 720px;
}
.digit-rail-wrap { overflow-x: auto; padding-bottom: 8px; }
.digit-node {
  aspect-ratio: 1 / 1;
  min-height: 62px;
  border-radius: 50%;
  border: 2px solid #31445a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a1622;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.digit-node b { font-size: 25px; line-height: 1; }
.digit-node small { color: var(--muted); margin-top: 4px; font-size: 10px; }
.digit-node.even { border-color: rgba(51,208,170,.40); }
.digit-node.odd { border-color: rgba(242,170,76,.42); }
.digit-node.current { transform: translateY(-4px) scale(1.07); box-shadow: 0 0 0 5px rgba(255,75,110,.10), 0 12px 30px rgba(0,0,0,.22); border-color: var(--accent); background: #1c1721; }

.moving-cursor {
  position: absolute;
  left: 0;
  top: 4px;
  width: 24px;
  height: 24px;
  transform: translateX(-50%);
  transition: left .22s cubic-bezier(.2,.8,.2,1);
  pointer-events: none;
  z-index: 3;
}
.moving-cursor::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid var(--accent);
}
.moving-cursor span { display: block; width: 18px; height: 18px; margin: 0 auto; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px rgba(255,75,110,.13); }

.recent-flow { display: flex; align-items: center; gap: 12px; margin-top: 15px; min-height: 30px; }
.recent-digits { display: flex; gap: 5px; flex-wrap: wrap; }
.recent-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px; font-weight: 900; font-size: 12px;
  background: #0a1622; border: 1px solid var(--line);
}
.recent-chip.even { color: var(--even); }
.recent-chip.odd { color: var(--odd); }

.signal-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; margin-bottom: 18px; }
.signal-card { position: relative; overflow: hidden; }
.signal-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: #53677c; }
.signal-card.even::before { background: var(--even); }
.signal-card.odd::before { background: var(--odd); }
.signal-card.wait::before { background: var(--warn); }
.signal-card.entry { box-shadow: 0 0 0 1px rgba(51,208,170,.4), 0 18px 60px rgba(0,0,0,.28), 0 0 45px rgba(51,208,170,.11); }
.signal-label { font-size: clamp(30px, 5vw, 62px); font-weight: 950; letter-spacing: -.04em; margin: 2px 0 18px; }
.signal-card.even .signal-label { color: var(--even); }
.signal-card.odd .signal-label { color: var(--odd); }
.signal-card.wait .signal-label { color: var(--warn); }
.confidence-line, .countdown-wrap { display: flex; justify-content: space-between; gap: 20px; align-items: baseline; color: var(--muted); }
.confidence-line strong, .countdown-wrap strong { color: var(--text); font-size: 25px; }
.confidence-track { height: 10px; margin: 8px 0 18px; background: #06111b; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.confidence-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--warn), var(--accent), var(--even)); transition: width .25s ease; }
.signal-reason { line-height: 1.55; color: #c8d5df; margin-top: 17px; }
.risk-note { margin: 14px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.dominance-card h2 { margin: 4px 0 19px; font-size: clamp(25px, 4vw, 42px); }
.dominance-stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.dominance-stats div { padding: 12px; border: 1px solid var(--line); background: #08131e; border-radius: 12px; }
.dominance-stats span { display: block; color: var(--muted); font-size: 11px; }
.dominance-stats strong { display: block; margin-top: 4px; font-size: 21px; }
.split-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #06111b; margin: 16px 0 10px; }
.split-even { background: var(--even); transition: width .25s ease; }
.split-odd { background: var(--odd); transition: width .25s ease; }

.window-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.window-card { border: 1px solid var(--line); background: #08131e; border-radius: 14px; padding: 16px; }
.window-title, .ratio-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.window-title span { color: var(--muted); font-size: 11px; }
.ratio-row { margin-top: 14px; }
.ratio-row span { color: var(--muted); font-weight: 800; font-size: 12px; }
.ratio-row strong { font-size: 18px; }
.ratio-bar { height: 10px; margin-top: 8px; background: var(--odd); border-radius: 999px; overflow: hidden; }
.even-fill { height: 100%; background: var(--even); transition: width .25s ease; }

.diagnostics-card { margin-top: 18px; }
#logOutput { margin: 0; max-height: 230px; overflow: auto; white-space: pre-wrap; color: #b9c9d6; background: #06111b; border: 1px solid var(--line); border-radius: 12px; padding: 14px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

@media (max-width: 980px) {
  .control-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .market-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .signal-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app-shell { width: min(100% - 18px, 1480px); padding-top: 18px; }
  .hero { flex-direction: column; }
  .status-stack { text-align: left; }
  .control-grid, .market-strip, .window-grid { grid-template-columns: 1fr; }
  .card { padding: 17px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .recent-flow { align-items: flex-start; flex-direction: column; }
}
