
:root {
  --bg-deep: #05070a;
  --bg-surface: #0e1218;
  --bg-elevated: #161c24;
  --border: #222b36;
  --text-main: #f1f5f9;
  --text-dim: #94a3b8;
  --bid: #22c55e;
  --bid-muted: rgba(34, 197, 94, 0.15);
  --ask: #ef4444;
  --ask-muted: rgba(239, 68, 68, 0.15);
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --stop-ord: #a855f7; /* Purple for stops */
  --highlight: #eab308;
  --warning: #f59e0b;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  overflow-x: hidden;
  user-select: none; /* Prevent selection while clicking rapid fire */
  touch-action: manipulation;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.narrow { max-width: 600px; }

/* Header */
.main-header {
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.nav-wrapper { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.logo { font-size: 1.4rem; font-weight: 800; text-decoration: none; color: white; }
.logo span { color: var(--accent); }
.nav-links { display: flex; list-style: none; gap: 1.5rem; }
.nav-links a { color: var(--text-dim); text-decoration: none; font-size: 0.85rem; transition: 0.2s; }
.nav-links a:hover, .nav-links a.active { color: var(--accent-light); }

/* Stages */
.app-stage { min-height: calc(100vh - 60px); }

/* Setup Screen */
.setup-screen { display: flex; align-items: center; padding: 4rem 0; }
.setup-card { background: var(--bg-surface); border: 1px solid var(--border); padding: 2.5rem; border-radius: 12px; width: 100%; }
.setup-card h1 { margin-bottom: 0.5rem; font-size: 1.5rem; }
.setup-card p { color: var(--text-dim); margin-bottom: 2rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; margin-bottom: 0.5rem; }
select, input { width: 100%; background: var(--bg-elevated); border: 1px solid var(--border); padding: 0.75rem; color: white; border-radius: 6px; outline: none; }

/* Simulator Layout */
.simulator-wrapper {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  background: var(--border);
  gap: 1px;
}

.panel { background: var(--bg-surface); display: flex; flex-direction: column; overflow: hidden; }
.panel-header { background: var(--bg-elevated); padding: 0.6rem 1rem; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; color: var(--text-dim); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }

/* DOM Ladder */
.dom-container { flex: 1; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.dom-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.8rem; }
.dom-table th { position: sticky; top: 0; background: var(--bg-elevated); z-index: 10; padding: 0.5rem; font-size: 0.65rem; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.dom-row { height: 28px; border-bottom: 1px solid rgba(255,255,255,0.02); cursor: crosshair; transition: background 0.1s; }
.dom-row:hover { background: rgba(255,255,255,0.05); }
.dom-row.current-price { background: rgba(59, 130, 246, 0.15); box-shadow: inset 0 0 0 1px var(--accent); font-weight: bold; }

/* Selection State for Move Order */
.dom-row.row-selected { background: rgba(234, 179, 8, 0.2); animation: pulse 1s infinite; }

@keyframes pulse {
  0% { box-shadow: inset 0 0 0 1px var(--highlight); }
  50% { box-shadow: inset 0 0 0 2px var(--highlight); }
  100% { box-shadow: inset 0 0 0 1px var(--highlight); }
}

.cell { text-align: center; position: relative; border-right: 1px solid rgba(255,255,255,0.02); }
.cell-price { font-weight: 700; color: var(--text-main); width: 80px; }
.cell-bid { color: var(--bid); background: var(--bid-muted); width: 100px; }
.cell-ask { color: var(--ask); background: var(--ask-muted); width: 100px; }
.cell-imb { width: 30px; font-weight: 900; font-size: 0.65rem; }
.cell-profile { width: 120px; text-align: left; }

/* Order Badges */
.ord-badge { display: inline-block; padding: 1px 4px; border-radius: 2px; font-size: 0.65rem; color: white; margin-left: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.5); }
.ord-limit { background: var(--accent); }
.ord-stop { background: var(--stop-ord); }

.imb-buy { color: var(--bid); background: rgba(34, 197, 94, 0.1); }
.imb-sell { color: var(--ask); background: rgba(239, 68, 68, 0.1); }

.depth-bar { position: absolute; top: 0; bottom: 0; left: 0; opacity: 0.4; z-index: 1; pointer-events: none; }
.depth-val { position: relative; z-index: 2; }
.vol-bar { height: 70%; background: #475569; position: absolute; left: 0; top: 15%; opacity: 0.3; }
.vol-text { position: relative; z-index: 2; padding-left: 0.5rem; color: var(--text-dim); font-size: 0.7rem; }

/* Tape */
.tape-list { flex: 1; overflow-y: auto; font-family: var(--font-mono); font-size: 0.75rem; }
.tape-row { display: flex; justify-content: space-between; padding: 0.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.02); }
.tape-row.buy { color: var(--bid); }
.tape-row.sell { color: var(--ask); }

/* Delta */
.delta-pos { color: var(--bid); }
.delta-neg { color: var(--ask); }
.delta-neutral { color: var(--text-dim); }
.mini-chart-container { padding: 4px 1rem; height: 12px; display: flex; align-items: center; }

/* Trading HUD */
.order-entry { padding: 1rem; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.stat-box { background: var(--bg-elevated); padding: 0.5rem; border-radius: 4px; text-align: center; border: 1px solid var(--border); }
.stat-label { font-size: 0.6rem; text-transform: uppercase; color: var(--text-dim); display: block; margin-bottom: 0.25rem; font-weight: 700; }
.stat-val { font-size: 1rem; font-weight: 700; font-family: var(--font-mono); transition: color 0.3s; }
.pos-long { color: var(--bid); }
.pos-short { color: var(--ask); }

/* Strategy Controls */
.strategy-controls { background: var(--bg-elevated); padding: 0.75rem; border-radius: 4px; border: 1px solid var(--border); margin-bottom: 1rem; }
.strat-toggle { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; margin-bottom: 0.5rem; cursor: pointer; }
.strat-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.strat-input-group label { font-size: 0.6rem; color: var(--text-dim); display: block; margin-bottom: 2px; }
.strat-input-group input { padding: 4px; font-size: 0.8rem; background: var(--bg-surface); text-align: center; }

.btn { border: none; border-radius: 4px; cursor: pointer; font-weight: 700; transition: 0.2s; font-size: 0.75rem; padding: 0.5rem; }
.btn-primary { background: var(--accent); color: white; }
.btn-danger { background: var(--ask); color: white; }
.btn-warning { background: var(--warning); color: black; }
.btn-buy { background: var(--bid); color: #000; }
.btn-sell { background: var(--ask); color: #fff; }
.btn-flatten { background: var(--text-dim); color: #000; grid-column: span 2; }
.btn-xs { font-size: 0.65rem; padding: 0.2rem 0.5rem; }
.btn:active { opacity: 0.8; transform: translateY(1px); }

/* Toasts */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { 
    background: var(--bg-elevated); 
    border-left: 4px solid var(--accent); 
    color: white; 
    padding: 12px 20px; 
    border-radius: 4px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.5); 
    font-size: 0.85rem; 
    animation: slideIn 0.3s forwards, fadeOut 0.3s forwards 2.7s; 
    pointer-events: auto;
}
.toast.success { border-left-color: var(--bid); }
.toast.danger { border-left-color: var(--ask); }
.toast.info { border-left-color: var(--accent); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Panic Mode */
.panic-mode .simulator-wrapper {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
    border: 2px solid var(--ask);
}
@keyframes shake { 
    10%, 90% { transform: translate3d(-1px, 0, 0); } 
    20%, 80% { transform: translate3d(2px, 0, 0); } 
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); } 
    40%, 60% { transform: translate3d(4px, 0, 0); } 
}

/* Flash Animations */
@keyframes flashGreen { 0% { color: var(--text-main); } 20% { color: var(--bid); text-shadow: 0 0 10px var(--bid); } 100% { color: var(--text-main); } }
@keyframes flashRed { 0% { color: var(--text-main); } 20% { color: var(--ask); text-shadow: 0 0 10px var(--ask); } 100% { color: var(--text-main); } }

.flash-up { animation: flashGreen 0.5s ease; }
.flash-down { animation: flashRed 0.5s ease; }

/* Review Screen */
.review-screen { display: flex; align-items: center; padding: 4rem 0; }
.review-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 0.75rem 0; }

/* Footer */
.footer { background: var(--bg-deep); border-top: 1px solid var(--border); padding: 4rem 0; margin-top: 4rem; color: var(--text-dim); font-size: 0.85rem; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 3rem; margin-bottom: 3rem; }
.footer-links h4 { color: white; margin-bottom: 1rem; }
.footer-links ul { list-style: none; }
.footer-links li { margin-bottom: 0.5rem; }
.footer-links a { color: inherit; text-decoration: none; }
.footer-links a:hover { color: var(--accent); }
.disclaimer { font-size: 0.7rem; border-top: 1px solid var(--border); padding-top: 2rem; text-align: center; }

/* SEO prose */
.seo-content { padding: 5rem 0; }
.prose { max-width: 850px; margin: 0 auto; line-height: 1.7; }
.prose h2 { color: white; margin: 2.5rem 0 1rem; font-size: 2rem; }
.prose h3 { color: var(--accent-light); margin: 2rem 0 1rem; }
.prose p { margin-bottom: 1.5rem; font-size: 1.05rem; }
.prose ul { margin-bottom: 1.5rem; padding-left: 1.5rem; }
.prose li { margin-bottom: 0.5rem; }

/* Mobile Optimization */
@media (max-width: 1024px) {
  .simulator-wrapper { grid-template-columns: 1fr; height: auto; }
  .panel { height: 450px; }
  .mobile-hide { display: none; }
  .hide-sm { display: none; }
  
  /* On mobile, prioritize the ladder input */
  .cell-price { width: 60px; }
  .cell-bid, .cell-ask { width: 80px; }
  .dom-row { height: 32px; /* Bigger touch targets */ }
}
