:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2330;
  --border: #2b3240;
  --text: #e6edf3;
  --muted: #8b949e;
  --green: #26d07c;
  --red: #ff5c5c;
  --gold: #e3b341;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  height: 100vh;
  overflow: hidden;
}

#topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

#logo { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
#logo span { color: var(--green); }

.stat label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.stat span { font-size: 15px; }

#dayProgress {
  flex: 0 0 120px;
  height: 6px;
  background: var(--panel2);
  border-radius: 3px;
  overflow: hidden;
}
#dayFill { height: 100%; width: 0%; background: var(--green); transition: width 0.4s linear; }

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

main {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 280px;
  gap: 10px;
  padding: 10px;
  height: calc(100vh - 52px);
}

#stockPanel, #rightPanel > div {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 10px 12px 6px;
}

#stockPanel { display: flex; flex-direction: column; }
#stockList { overflow-y: auto; flex: 1; }

.listHead {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--gold);
  padding: 10px 12px 4px;
  border-top: 1px solid var(--border);
}
.listHead:first-child { border-top: none; }

.srow {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  padding: 8px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.srow:hover { background: var(--panel2); }
.srow.sel { background: var(--panel2); border-left-color: var(--green); }
.s-tick { font-size: 14px; font-weight: 700; }
.s-price { font-size: 14px; text-align: right; }
.s-name { font-size: 10px; color: var(--muted); grid-column: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-chg { font-size: 11px; text-align: right; }

#center { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

#chartHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
#selName { font-size: 16px; font-weight: 700; }
#selMeta { font-size: 11px; color: var(--muted); }
#chartHeadRight { text-align: right; }
#selPrice { font-size: 20px; }
#selChg { font-size: 12px; }

#chartWrap {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 0;
  position: relative;
}
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }

#tradeBar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
#posInfo { font-size: 12px; color: var(--muted); }
.tradeBtns { display: flex; gap: 6px; }

button {
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
}
button:hover { filter: brightness(1.25); }
button:active { transform: scale(0.97); }
button.buy { border-color: var(--green); color: var(--green); }
button.sell { border-color: var(--red); color: var(--red); }

#rightPanel { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
#positions { flex: 0 0 auto; max-height: 40%; display: flex; flex-direction: column; }
#posList { overflow-y: auto; padding-bottom: 6px; }
#news { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#newsList { overflow-y: auto; flex: 1; padding-bottom: 6px; }

.prow { padding: 6px 12px; font-size: 12px; cursor: pointer; }
.prow:hover { background: var(--panel2); }
.prow .pl1 { display: flex; justify-content: space-between; }
.prow .pl2 { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.empty { padding: 6px 12px; font-size: 11px; color: var(--muted); }

.nitem { padding: 6px 12px; font-size: 11px; border-left: 3px solid var(--border); margin: 4px 0; }
.nitem.good { border-left-color: var(--green); }
.nitem.bad { border-left-color: var(--red); }
.nitem .nday { color: var(--muted); margin-right: 6px; }
.nitem.tweet { background: rgba(56, 139, 253, 0.08); border-left-color: #388bfd; font-style: italic; }
.nitem.tweet b { color: #58a6ff; font-style: normal; }
.nitem.analyst { background: rgba(38, 208, 124, 0.07); border-left-color: var(--green); color: #b8e6cf; }
.nitem.ipo { background: rgba(227, 179, 65, 0.08); border-left-color: var(--gold); }
.nitem.card { border-left-color: #b18cff; background: rgba(177, 140, 255, 0.08); }
.nitem.card b { color: #b18cff; }
.nitem.handler {
  background: rgba(255, 92, 92, 0.12);
  border-left-color: var(--red);
  color: #ffb3b3;
  font-weight: 700;
}

.ipoBadge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: #0d1117;
  background: var(--gold);
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 6px;
  vertical-align: 2px;
}
.regime { margin-left: 6px; font-size: 11px; }
.regime.flat { color: var(--muted); }

#cardBar {
  display: flex;
  gap: 8px;
  min-height: 62px;
}
.card {
  flex: 1;
  max-width: 170px;
  background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid #b18cff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.1s;
}
.card:hover { transform: translateY(-3px); }
.card:active { transform: scale(0.97); }
.cardName { font-size: 12px; font-weight: 700; color: #b18cff; }
.cardDesc { font-size: 10px; color: var(--muted); margin-top: 2px; }
.cardEmpty {
  flex: 1;
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
}

#skipBtn { margin-left: auto; border-color: var(--gold); color: var(--gold); }
#skipBtn:disabled { opacity: 0.35; cursor: default; border-color: var(--border); color: var(--muted); }
#skipBtn:disabled:hover { filter: none; }

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
#overlay.hidden { display: none; }

#overlayCard {
  width: 440px;
  max-width: 92vw;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
}
#overlayTitle { font-size: 34px; font-weight: 700; letter-spacing: 2px; }
#overlayTitle span { color: var(--green); }
#overlayBody { margin: 18px 0 24px; }
#overlayBody .tagline { color: var(--gold); font-size: 14px; margin-bottom: 12px; }
#overlayBody p { font-size: 12px; color: var(--muted); line-height: 1.6; }
#overlayBtn {
  font-size: 14px;
  padding: 12px 28px;
  border-color: var(--green);
  color: var(--green);
}
#highScore { margin-top: 16px; font-size: 11px; color: var(--muted); }

.statsGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0 6px;
  text-align: left;
}
.statsGrid > div {
  background: var(--panel2);
  border-radius: 8px;
  padding: 10px 12px;
}
.statsGrid label { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.statsGrid span { font-size: 16px; }

body.crashing { animation: crash 0.12s linear infinite; filter: saturate(1.6) contrast(1.1); }
@keyframes crash {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-5px, 3px); }
  50% { transform: translate(4px, -4px); }
  75% { transform: translate(-3px, -2px); }
  100% { transform: translate(0, 0); }
}

#deathFx {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.7s;
}
#deathFx.show { opacity: 1; }
#callCard { text-align: center; }
#callAvatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--panel2);
  border: 2px solid var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: var(--red);
  margin: 0 auto;
  animation: ringPulse 1.1s ease-out infinite;
}
#callCard.live #callAvatar { animation: none; border-color: var(--green); color: var(--green); }
#callCard.ended #callAvatar { animation: none; opacity: 0.4; }
#callName { font-size: 20px; letter-spacing: 4px; margin-top: 20px; color: var(--text); }
#callState { font-size: 13px; color: var(--muted); margin-top: 8px; letter-spacing: 2px; min-height: 18px; }
#callCard.live #callState { color: var(--green); }
#callCard.ended #callState { color: var(--red); }
@keyframes ringPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 92, 92, 0.5); }
  100% { box-shadow: 0 0 0 30px rgba(255, 92, 92, 0); }
}
#deathFx.bang::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  animation: bangFlash 0.55s ease-out forwards;
}
@keyframes bangFlash {
  0% { opacity: 1; }
  30% { opacity: 0.6; background: #ff5c5c; }
  100% { opacity: 0; }
}

#splash {
  position: fixed;
  inset: 0;
  background: #07090d;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.9s;
  cursor: pointer;
}
#splash.out { opacity: 0; pointer-events: none; }
#splashInner { text-align: center; }
#splashSpark { font-size: 30px; color: var(--green); animation: sparkPulse 1.6s ease-in-out infinite; }
#splashTitle { font-size: 22px; letter-spacing: 6px; color: var(--text); margin-top: 16px; animation: glowIn 1.4s ease-out both; }
#splashLine { height: 2px; width: 0; background: var(--green); margin: 18px auto 0; animation: lineGrow 1.8s 0.3s ease-out forwards; }
#splashSub { font-size: 11px; color: var(--muted); letter-spacing: 3px; margin-top: 14px; animation: glowIn 1.4s 0.8s ease-out both; }
@keyframes glowIn {
  from { opacity: 0; filter: blur(6px); transform: translateY(8px); }
  to { opacity: 1; filter: none; transform: none; }
}
@keyframes lineGrow { to { width: 280px; } }
@keyframes sparkPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
}
