:root {
  --bg: #0a0e12;
  --card: #111827;
  --muted: #9ca3af;
  --text: #e5e7eb;
  --border: #1f2937;
  --accent: #a78bfa;
  --good: #22c55e;
  --hot: #f59e0b;
  --fire: #ef4444;
  --bad: #f87171;
  --warn: #fbbf24;
  --casino-green: #064e3b;
  --casino-felt: #065f46;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  background: linear-gradient(135deg, #0a0e12 0%, #111827 50%, #0f172a 100%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(17, 24, 39, 0.95);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header h1 { font-size: 18px; font-weight: 700; }

.header-controls { display: flex; align-items: center; gap: 12px; }

.status {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.15);
  color: var(--good);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
}

.btn-icon:hover { background: rgba(255,255,255,0.05); }

/* Main Grid Layout */
.main-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
  overflow: hidden;
  gap: 0;
}

@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* Sidebar */
.sidebar {
  background: rgba(17, 24, 39, 0.9);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.panel.compact { padding: 8px; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
  color: #c4b5fd;
}

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
}

textarea {
  width: 100%;
  height: 60px;
  resize: none;
  border-radius: 6px;
  border: 1px solid var(--border);
  padding: 6px 8px;
  background: #0b1220;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
}

.btn-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(17, 24, 39, 0.6);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(180deg, #7c3aed 0%, #6d28d9 100%);
  border-color: #7c3aed;
  color: #fff;
}

.btn:hover { opacity: 0.9; }

.inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.inline-field label {
  font-size: 11px;
  color: var(--muted);
  min-width: 40px;
}

.inline-field input {
  flex: 1;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font-size: 12px;
}

select.full-width {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font-size: 11px;
}

.stats-row {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.stats-row .stat {
  flex: 1;
  text-align: center;
  padding: 4px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
}

.stats-row .stat .label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
}

.stats-row .stat .value {
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.pending-bets {
  margin-top: 6px;
  font-size: 10px;
  color: var(--muted);
  max-height: 60px;
  overflow-y: auto;
}

.warnings {
  margin-top: 4px;
  font-size: 10px;
  color: var(--warn);
}

/* Center Panel */
.center-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px;
  gap: 8px;
}

/* Top 3 Models Bar */
.models-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex-shrink: 0;
}

.model-card {
  background: rgba(17, 24, 39, 0.8);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  transition: all 0.2s;
}

.model-card.wait { border-color: var(--muted); opacity: 0.7; }
.model-card.no_bet { border-color: var(--bad); }
.model-card.ready { border-color: var(--good); background: rgba(34, 197, 94, 0.1); }

.model-name {
  font-size: 11px;
  font-weight: 700;
  color: #c4b5fd;
  margin-bottom: 4px;
}

.model-status {
  font-size: 16px;
  font-weight: 800;
}

.model-card.wait .model-status { color: var(--muted); }
.model-card.no_bet .model-status { color: var(--bad); }
.model-card.ready .model-status { color: var(--good); }

.model-detail {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  min-height: 14px;
}

/* Bias Stats Bar */
.bias-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
}

.dice-faces {
  display: flex;
  gap: 8px;
}

.dice-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.dice-face.hot { border-color: var(--hot); background: rgba(245, 158, 11, 0.15); }
.dice-face.fire { border-color: var(--fire); background: rgba(239, 68, 68, 0.15); }

.face-num { font-size: 18px; }

.freq {
  font-size: 10px;
  font-weight: 700;
  margin-top: 2px;
}

.bias-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}

.bias-info strong { color: var(--text); }

.hot-bets-indicator {
  flex: 1;
  text-align: right;
  font-size: 11px;
}

/* Next Bet Recommendation Bar */
.next-bet-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.15) 0%, rgba(17, 24, 39, 0.8) 100%);
  border: 1px solid var(--good);
  border-radius: 10px;
  flex-shrink: 0;
}

.next-bet-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.next-bet-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--good);
}

.next-bet-details {
  font-size: 11px;
  color: var(--text);
}

.next-bet-bar.low-confidence {
  border-color: var(--muted);
  background: rgba(17, 24, 39, 0.8);
}

.next-bet-bar.low-confidence .next-bet-name {
  color: var(--muted);
}

/* Casino Bet Table */
.bet-table {
  flex: 1;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--casino-green) 0%, var(--casino-felt) 100%);
  border: 3px solid #854d0e;
  border-radius: 12px;
  padding: 10px;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.4);
}

.bet-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  justify-content: center;
}

.bet-row.last-combo-row { justify-content: flex-start; padding-left: calc(50% - 35px); }

.bet-cell {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 70px;
}

.bet-cell.small-cell {
  min-width: 50px;
  padding: 6px 8px;
}

.bet-cell:hover {
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.bet-cell.hot {
  border-color: var(--hot);
  background: rgba(245, 158, 11, 0.2);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.bet-cell.fire {
  border-color: var(--fire);
  background: rgba(239, 68, 68, 0.25);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
  animation: pulse 1.5s infinite;
}

.bet-cell.selected {
  border-color: var(--accent);
  background: rgba(167, 139, 250, 0.2);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.6); }
}

.bet-name {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.bet-range {
  font-size: 9px;
  color: rgba(255,255,255,0.6);
}

.bet-winpct {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 2px;
}

.bet-cell.hot .bet-winpct,
.bet-cell.fire .bet-winpct {
  color: #fff;
  font-weight: 700;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 16px; }

.modal-body {
  overflow-y: auto;
  padding: 12px;
}

.details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.details-table th, .details-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.details-table th {
  background: rgba(0,0,0,0.2);
  color: #c4b5fd;
  font-size: 11px;
}

/* Resolved Bets Panel */
.resolved-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 100;
  transition: transform 0.2s;
}

.resolved-panel.collapsed { transform: translateY(calc(100% - 36px)); }

.resolved-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.resolved-header:hover { background: rgba(255,255,255,0.03); }

.resolved-body {
  max-height: 200px;
  overflow-y: auto;
  padding: 0 12px 12px;
}

.resolved-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.resolved-table th, .resolved-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.resolved-table th {
  background: rgba(0,0,0,0.2);
  color: var(--muted);
  font-size: 10px;
}

.resolved-table .win { color: var(--good); }
.resolved-table .loss { color: var(--bad); }

/* Desktop sidebar textarea - resizable, narrow */
.sidebar textarea {
  width: 100%;
  min-height: 80px;
  max-height: 300px;
  resize: vertical;
}

/* Mobile Controls */
.mobile-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 8px;
  z-index: 200;
  display: none;
}

.mobile-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.mobile-input {
  flex: 1;
  height: 36px;
  min-height: 36px;
  resize: none;
  font-size: 14px;
}

.mobile-bet-btn {
  width: 100%;
  padding: 10px;
  font-size: 14px;
}

/* Mobile Bet Modal */
.mobile-bet-content {
  width: 95%;
  max-width: 400px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* Help Modal */
.help-content {
  max-width: 600px;
  max-height: 85vh;
}

.help-section {
  background: rgba(0,0,0,0.2);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.help-section p {
  margin: 6px 0;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-section h3 {
  font-size: 14px;
  margin-bottom: 8px;
  color: #c4b5fd;
}

.color-box {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
}

.color-box.fire { background: var(--fire); }
.color-box.hot { background: var(--hot); }
.color-box.warm { background: #eab308; }
.color-box.normal { background: rgba(255,255,255,0.15); border: 1px solid var(--border); }

.model-docs {
  display: grid;
  gap: 10px;
}

.model-doc {
  background: rgba(0,0,0,0.15);
  padding: 10px;
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.model-doc h4 {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 6px;
}

.model-doc p {
  margin: 3px 0;
  font-size: 11px;
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  html, body { overflow: auto; }
  
  .app {
    height: auto;
    min-height: 100vh;
    padding-bottom: 100px;
  }
  
  .main-grid {
    grid-template-columns: 1fr;
  }
  
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
  .mobile-controls { display: block; }
  
  .center-panel {
    padding: 4px;
    gap: 6px;
  }
  
  .models-bar {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  
  .model-card {
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .model-name { font-size: 10px; }
  .model-status { font-size: 14px; }
  .model-detail { font-size: 9px; }
  
  .bias-bar {
    flex-wrap: wrap;
    padding: 6px 8px;
    gap: 6px;
  }
  
  .dice-faces {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }
  
  .dice-face {
    padding: 2px 6px;
  }
  
  .face-num { font-size: 14px; }
  .freq { font-size: 9px; }
  
  .bet-table {
    padding: 6px;
    overflow-y: auto;
    max-height: calc(100vh - 350px);
  }
  
  .bet-row {
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
  }
  
  .bet-cell {
    min-width: 50px;
    padding: 4px 6px;
    flex: 1 1 auto;
  }
  
  .bet-cell.small-cell {
    min-width: 40px;
    padding: 3px 4px;
  }
  
  .bet-name { font-size: 9px; }
  .bet-range { font-size: 7px; }
  .bet-winpct { font-size: 8px; }
  
  .hot-bets-indicator {
    font-size: 9px;
    text-align: center;
    width: 100%;
  }
  
  .resolved-panel { display: none; }
}

/* Desktop - show sidebar, hide mobile */
@media (min-width: 769px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: flex !important; }
}

/* Utility */
.text-good { color: var(--good); }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.text-muted { color: var(--muted); }
