/* ============ STOCK SHARK 🦈 ============ */
:root {
  --bg: #0b1026;
  --bg2: #121a3a;
  --card: #1a2450;
  --card2: #223065;
  --line: #2c3a75;
  --text: #eef2ff;
  --dim: #93a0c9;
  --up: #22e07c;
  --dn: #ff4d6d;
  --gold: #ffd34d;
  --purple: #a78bfa;
  --blue: #4dc3ff;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", -apple-system, sans-serif;
  background: radial-gradient(1200px 700px at 70% -10%, #1c2a5e 0%, var(--bg) 55%);
  color: var(--text);
  overflow: hidden;
  user-select: none;
}
button { font-family: inherit; cursor: pointer; border: none; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ============ HEADER ============ */
header {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px;
  background: linear-gradient(180deg, #141d45, #101736);
  border-bottom: 2px solid var(--line);
  flex: 0 0 auto;
}
#logo { font-size: 24px; font-weight: 900; letter-spacing: 1px; color: var(--blue); white-space: nowrap; }
#logo span { color: var(--gold); }

#rankBox { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
#rankBadge {
  font-size: 34px; width: 54px; height: 54px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 2px solid var(--gold); border-radius: 50%;
  box-shadow: 0 0 14px rgba(255, 211, 77, .35);
}
#rankInfo { min-width: 140px; max-width: 340px; flex: 1 1 auto; }
#rankName { font-weight: 800; color: var(--gold); font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rankName .who { color: #fff; font-size: 21px; font-weight: 900; }
#rankBarWrap { height: 10px; background: #0d1330; border-radius: 6px; overflow: hidden; margin: 3px 0; border: 1px solid var(--line); }
#rankBar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--blue), var(--gold)); border-radius: 6px; transition: width .4s; }
#rankNext { font-size: 11px; color: var(--dim); }

#equityBox { text-align: right; }
#equity { font-size: 30px; font-weight: 900; transition: color .2s; }
#equity.up { color: var(--up); text-shadow: 0 0 12px rgba(34,224,124,.5); }
#equity.dn { color: var(--dn); text-shadow: 0 0 12px rgba(255,77,109,.5); }
#equitySub { font-size: 12px; color: var(--dim); }

#hdrBtns { display: flex; gap: 8px; }
#hdrBtns button {
  font-size: 18px; width: 42px; height: 42px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
}
#hdrBtns button:hover { background: var(--card2); }

/* ============ MAIN GRID ============ */
main {
  display: grid;
  grid-template-columns: 215px 1fr 305px;
  gap: 12px; padding: 12px;
  flex: 1 1 auto; min-height: 0;
}

/* ============ STOCK LIST ============ */
#stockList { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.stockCard {
  background: var(--card); border: 2px solid transparent; border-radius: var(--radius);
  padding: 8px 10px; cursor: pointer; position: relative; flex: 0 0 auto;
  transition: transform .1s, border-color .15s;
}
.stockCard:hover { transform: translateX(3px); border-color: var(--line); }
.stockCard[draggable="true"] { cursor: grab; }
.stockCard.dragging { opacity: .55; border-color: var(--gold); }
.stockCard.active { border-color: var(--blue); background: var(--card2); box-shadow: 0 0 12px rgba(77,195,255,.25); }
.stockCard.market { background: linear-gradient(135deg, #1a2450, #253a7e); }
.scName { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scRow { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.scPrice { font-size: 12px; color: var(--dim); }
.scChg { font-size: 12px; font-weight: 800; }
.scChg.up { color: var(--up); } .scChg.dn { color: var(--dn); }
.scSpark { width: 100%; height: 22px; margin-top: 3px; }
.scPin { position: absolute; top: -7px; right: -4px; font-size: 15px; }

/* ============ CHART ============ */
#chartSec { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#chartHead { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 6px 8px; }
#chartTitle { font-size: 22px; font-weight: 900; }
#chartPriceBox { font-size: 20px; font-weight: 900; }
#chartChg { font-size: 15px; margin-left: 8px; }
#chartChg.up { color: var(--up); } #chartChg.dn { color: var(--dn); }
#chartWrap {
  position: relative; flex: 1 1 auto; min-height: 0;
  background: linear-gradient(180deg, #10173a, #0d1330);
  border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }
#pnlBadge {
  position: absolute; top: 12px; left: 12px; padding: 8px 14px;
  border-radius: 12px; font-size: 20px; font-weight: 900;
  background: rgba(10, 15, 40, .82); border: 2px solid var(--line);
  pointer-events: none;
}
#pnlBadge.up { color: var(--up); border-color: var(--up); }
#pnlBadge.dn { color: var(--dn); border-color: var(--dn); }
#pnlBadge .sub { display: block; font-size: 11px; color: var(--dim); font-weight: 400; }

/* ============ SPEED CONTROLS ============ */
#controls { display: flex; gap: 8px; justify-content: center; padding-top: 10px; flex: 0 0 auto; }
.spd {
  font-size: 15px; font-weight: 800; padding: 9px 16px; border-radius: 12px;
  background: var(--card); color: var(--text); border: 2px solid var(--line);
}
.spd:hover { background: var(--card2); }
.spd.on { background: var(--blue); color: #06122b; border-color: var(--blue); box-shadow: 0 0 12px rgba(77,195,255,.5); }

/* ============ RIGHT COLUMN ============ */
#rightCol { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.panel { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; }
.panelTitle { font-weight: 900; font-size: 14px; margin-bottom: 8px; color: var(--dim); letter-spacing: .5px; }
#tradePanel { flex: 0 0 auto; }
#newsPanel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
#newsList { overflow-y: auto; flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; }
.newsItem { font-size: 14px; line-height: 1.35; padding: 8px 10px; background: #141d45; border-radius: 9px; border-left: 3px solid var(--line); }
.newsItem.up { border-left-color: var(--up); }
.newsItem.dn { border-left-color: var(--dn); }
.newsItem.gold { border-left-color: var(--gold); }
.newsDay { color: var(--dim); font-size: 11px; }

/* ============ TRADE PANEL ============ */
.bigBtn {
  width: 100%; padding: 13px; border-radius: 12px; font-size: 17px; font-weight: 900;
  margin-top: 8px; color: #06122b; transition: transform .08s;
}
.bigBtn:active { transform: scale(.97); }
.bigBtn.buy { background: linear-gradient(180deg, #2df08c, #17b864); box-shadow: 0 3px 0 #0e8a49; }
.bigBtn.short { background: linear-gradient(180deg, #ff6584, #e03356); color: #fff; box-shadow: 0 3px 0 #a01f3c; }
.bigBtn.close { background: linear-gradient(180deg, #ffd34d, #f0b429); box-shadow: 0 3px 0 #b78312; font-size: 19px; }
.bigBtn:disabled { filter: grayscale(1) brightness(.6); cursor: not-allowed; }
.tpRow { display: flex; align-items: center; justify-content: space-between; margin: 6px 0; font-size: 13px; }
.tpRow .lbl { color: var(--dim); }
.tpRow .val { font-weight: 800; }
.tpRow .val.up { color: var(--up); } .tpRow .val.dn { color: var(--dn); }
#amtSlider { width: 100%; accent-color: var(--blue); height: 26px; }
.chips { display: flex; gap: 6px; margin: 4px 0; }
.chip {
  flex: 1; padding: 6px 4px; font-size: 12px; font-weight: 800; border-radius: 8px;
  background: #141d45; color: var(--text); border: 1px solid var(--line);
}
.chip:hover { background: var(--card2); border-color: var(--blue); }
.chip:disabled { opacity: .4; cursor: not-allowed; }
.chip.mini { flex: 0 0 auto; padding: 3px 9px; font-size: 11px; }
.chip.sel { background: var(--blue); color: #06122b; border-color: var(--blue); }
.sizeRow { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--dim); margin: 2px 0 8px; }
.inWrap { display: flex; align-items: center; gap: 5px; }
.numIn {
  width: 90px; padding: 5px 7px; border-radius: 8px; border: 1px solid var(--line);
  background: #0d1330; color: var(--text); font-family: inherit; font-size: 13px; font-weight: 700;
  text-align: right;
}
.numIn:focus { outline: none; border-color: var(--blue); }
.numIn.bad { border-color: var(--dn); }
.boostRow {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; font-weight: 800;
  padding: 7px 9px; border-radius: 9px; background: #141d45;
}
.boostRow.locked { color: var(--dim); }
.boostRow input { width: 18px; height: 18px; accent-color: var(--purple); }
.hint { font-size: 11px; color: var(--dim); margin-top: 6px; text-align: center; }
.divider { height: 1px; background: var(--line); margin: 10px 0; }

/* ============ DISCLAIMER ============ */
#disclaimer {
  position: fixed; bottom: 4px; right: 10px; z-index: 5;
  font-size: 10px; color: var(--dim); opacity: .55; pointer-events: none;
}

/* ============ TOASTS ============ */
#toasts {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none;
  align-items: center;
}
.toast {
  padding: 10px 20px; border-radius: 12px; font-weight: 900; font-size: 16px;
  background: var(--card); border: 2px solid var(--line); color: var(--text);
  animation: toastIn .25s ease-out, toastOut .4s ease-in 3.4s forwards;
  box-shadow: 0 6px 24px rgba(0,0,0,.5); max-width: 560px; text-align: center;
}
.toast.up { border-color: var(--up); color: var(--up); }
.toast.dn { border-color: var(--dn); color: var(--dn); }
.toast.gold { border-color: var(--gold); color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ============ FLASH & SHAKE & FX ============ */
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: 0; }
#flash.red { background: radial-gradient(circle, transparent 30%, rgba(255,45,85,.45)); animation: flashA .6s; }
#flash.green { background: radial-gradient(circle, transparent 30%, rgba(34,224,124,.4)); animation: flashA .6s; }
@keyframes flashA { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
body.shake #app { animation: shakeA .5s; }
@keyframes shakeA {
  0%, 100% { transform: translate(0); } 15% { transform: translate(-7px, 3px); }
  30% { transform: translate(6px, -4px); } 45% { transform: translate(-5px, -3px); }
  60% { transform: translate(5px, 3px); } 75% { transform: translate(-3px, 2px); } 90% { transform: translate(2px, -1px); }
}
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ============ MODAL ============ */
#modalWrap {
  position: fixed; inset: 0; background: rgba(5, 8, 24, .8); z-index: 80;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px);
}
#modalWrap.hidden, .hidden { display: none !important; }
#modal {
  background: linear-gradient(180deg, #1c2755, #141d45);
  border: 2px solid var(--line); border-radius: 20px; padding: 26px 30px;
  max-width: 560px; width: 92%; max-height: 86vh; overflow-y: auto;
  box-shadow: 0 20px 80px rgba(0,0,0,.6);
  animation: modalIn .25s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.9) translateY(20px); } }
#modal h1 { font-size: 26px; margin-bottom: 12px; text-align: center; }
#modal h2 { font-size: 17px; margin: 14px 0 6px; color: var(--gold); }
#modal p, #modal li { font-size: 14px; line-height: 1.55; color: var(--text); }
#modal ul, #modal ol { padding-left: 22px; margin: 6px 0; }
#modal .center { text-align: center; }
#modal .bigEmoji { font-size: 74px; text-align: center; display: block; margin: 6px 0; }
#modal .rankTitle { font-size: 32px; font-weight: 900; color: var(--gold); text-align: center; }
#modal .tagline { text-align: center; color: var(--dim); font-size: 15px; margin-top: 4px; }
#modal .statRow { display: flex; justify-content: space-between; font-size: 14px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
#modal .statRow b.up { color: var(--up); } #modal .statRow b.dn { color: var(--dn); }
#modal .reveal { background: #10173a; border-radius: 12px; padding: 10px 14px; margin-top: 10px; }
#modal .reveal div { font-size: 13px; padding: 2px 0; }
.modalBtn {
  display: block; width: 100%; margin-top: 18px; padding: 14px; border-radius: 12px;
  font-size: 18px; font-weight: 900; background: linear-gradient(180deg, #55c8ff, #2ba3e8);
  color: #06122b; box-shadow: 0 3px 0 #1a7ab0;
}
.modalBtn.danger { background: linear-gradient(180deg, #ff6584, #e03356); color: #fff; box-shadow: 0 3px 0 #a01f3c; }
.modalBtn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); box-shadow: none; font-size: 14px; padding: 10px; }
.setRow { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.setRow input { width: 20px; height: 20px; accent-color: var(--blue); }
.playerCard {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 8px 0;
  background: #141d45; border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.playerCard:hover { border-color: var(--blue); transform: translateX(3px); }
.pEmoji { font-size: 30px; }
.pInfo { display: flex; flex-direction: column; min-width: 0; }
.pInfo b { font-size: 17px; }
.pInfo small { color: var(--dim); font-size: 12px; }
.pDel { margin-left: auto; background: none; border: none; font-size: 16px; opacity: .45; padding: 6px; }
.pDel:hover { opacity: 1; }
.histRow { font-size: 12.5px; padding: 4px 0; color: var(--dim); }
.histRow b.up { color: var(--up); } .histRow b.dn { color: var(--dn); }

/* ============ SCROLLBARS ============ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ============ NARROW SCREENS ============ */
@media (max-width: 1050px) {
  body { overflow: auto; }
  #app { height: auto; }
  main { grid-template-columns: 1fr; }
  #stockList { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
  .stockCard { min-width: 140px; }
  #chartWrap { height: 46vh; flex: 0 0 auto; }
  header { flex-wrap: wrap; row-gap: 8px; }
  #logo { font-size: 19px; }
  #equity { font-size: 24px; }
  #equityBox { margin-left: auto; }
  #rankBox { order: 5; flex: 1 1 100%; }
  #rankInfo { max-width: none; }
}
