/* ============================================================
   Craps Simulator - Styles
   ============================================================ */

:root {
  --felt-green: #1a6b3c;
  --felt-dark: #145530;
  --felt-border: #c9a84c;
  --gold: #d4a843;
  --gold-light: #f0d78c;
  --red: #c0392b;
  --red-dark: #962d22;
  --blue: #2980b9;
  --bg-dark: #1a1a2e;
  --bg-panel: #16213e;
  --bg-card: #1e2d4a;
  --text: #e8e8e8;
  --text-muted: #8899aa;
  --text-bright: #ffffff;
  --win-green: #27ae60;
  --lose-red: #e74c3c;
  --push-yellow: #f39c12;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-panel);
  border-bottom: 2px solid var(--gold);
}

.app-header h1 {
  font-size: 1.5rem;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 1px;
}

.header-controls {
  display: flex;
  gap: 8px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--blue); color: white; }
.btn-secondary { background: #4a5568; color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-warning { background: var(--push-yellow); color: #222; }
.btn-info { background: var(--gold); color: #222; }
.btn-full { width: 100%; margin-top: 8px; }
.btn-sm { padding: 4px 10px; font-size: 0.75rem; }

.button-row {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  margin-top: 8px;
}

.button-row .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 4px;
  white-space: nowrap;
}

.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
}

.help-tip:hover {
  background: rgba(255,255,255,0.25);
  color: var(--text-light);
}

/* Layout */
.main-layout {
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  gap: 0;
  height: calc(100vh - 56px);
}

.left-panel, .right-panel {
  background: var(--bg-panel);
  padding: 12px;
  overflow-y: auto;
  border-right: 1px solid #2a3a5a;
}
.right-panel {
  border-right: none;
  border-left: 1px solid #2a3a5a;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.right-panel > .panel:not(.panel-log) {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.center-panel {
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow-y: scroll;
}

/* Panels */
.panel {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
}

.strategy-hash {
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.panel h2 {
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Controls */
.control-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.control-row .control-group {
  flex: 1;
  margin-bottom: 0;
}

.control-group {
  margin-bottom: 10px;
}

.control-group .hint {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.control-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.control-group input[type="number"],
.control-group input[type="text"],
.control-group select,
.control-group textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #3a4a6a;
  border-radius: 4px;
  background: var(--bg-dark);
  color: var(--text);
  font-size: 0.85rem;
}

.control-group input[type="range"] {
  width: calc(100% - 50px);
  vertical-align: middle;
}

.control-group input[type="checkbox"] {
  margin-right: 6px;
}

.control-group.checkbox-row label {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  cursor: pointer;
}


/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.stat {
  background: var(--bg-card);
  border-radius: 6px;
  padding: 8px 14px;
  flex: 1;
  min-width: 100px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-bright);
}

.stat-value.positive { color: var(--win-green); }
.stat-value.negative { color: var(--lose-red); }

/* ============================================================
   CRAPS TABLE
   ============================================================ */
.craps-table-container {
  flex-shrink: 0;
}

.craps-table {
  background: var(--felt-green);
  border: 6px solid var(--felt-border);
  border-radius: 16px;
  padding: 14px;
  position: relative;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.3), 0 4px 20px rgba(0,0,0,0.5);
  min-height: 340px;
}

/* Point Numbers Row */
.table-top-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.point-numbers {
  display: flex;
  gap: 4px;
  flex: 1;
}

.table-cell {
  border: 2px solid var(--felt-border);
  border-radius: 4px;
  padding: 8px;
  text-align: center;
  position: relative;
  transition: all 0.2s;
}

.point-cell {
  flex: 1;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 32px;
  cursor: default;
}

.point-cell.active-point {
  background: rgba(212, 168, 67, 0.25);
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(212, 168, 67, 0.4);
}

.cell-number {
  font-size: 1.2rem;
  font-weight: 800;
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.cell-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: white;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.cell-sub {
  display: block;
  font-size: 0.6rem;
  color: rgba(255,255,255,0.7);
  margin-top: 2px;
}

.come-cell, .dont-come-cell {
  width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 32px;
  background: rgba(255,255,255,0.05);
}

.dont-come-cell {
  background: rgba(192, 57, 43, 0.15);
}

/* Middle Area */
.table-middle {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.field-section {
  flex: 1;
}

.field-cell {
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
}

.pass-section {
  display: flex;
  gap: 4px;
  flex: 1;
}

.pass-cell, .dont-pass-cell {
  flex: 1;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 32px;
}

.pass-cell {
  background: rgba(255,255,255,0.05);
}

.dont-pass-cell {
  background: rgba(192, 57, 43, 0.15);
}

/* Center Props */
.table-center-props {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.prop-row {
  display: flex;
  gap: 4px;
}

.prop-cell {
  flex: 1;
  padding: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  background: rgba(192, 57, 43, 0.2);
}

.prop-cell.hardway {
  background: rgba(142, 68, 173, 0.2);
  font-size: 0.7rem;
}

/* Puck */
.puck-slot {
  position: absolute;
  top: 4px;
  right: 4px;
}

.puck-off {
  position: absolute;
  bottom: 14px;
  left: 20px;
}

.puck {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.65rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.puck.off {
  background: #222;
  color: white;
  border: 3px solid #555;
}

.puck.on {
  background: white;
  color: #222;
  border: 3px solid #ddd;
  animation: puckGlow 1.5s ease-in-out infinite;
}

@keyframes puckGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(255,255,255,0.4); }
  50% { box-shadow: 0 0 16px rgba(255,255,255,0.8); }
}

/* Bet Indicators */
.bet-indicator {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}

.bet-chip {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  margin: 1px;
}

.bet-chip.odds {
  background: #2c3e50;
  border-color: var(--gold);
}

.bet-chip.come {
  background: #8e44ad;
}

.bet-chip.dont {
  background: #2c3e50;
  border-color: var(--red);
}

/* Dice */
.dice-area {
  position: absolute;
  bottom: 14px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.die {
  width: 52px;
  height: 52px;
  background: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  transition: transform 0.15s;
}

.die.rolling {
  animation: dieRoll 0.3s ease-in-out;
}

@keyframes dieRoll {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

.die-face {
  font-size: 1.8rem;
  color: #222;
  font-weight: 900;
}

.dice-total {
  background: rgba(0,0,0,0.6);
  color: var(--gold);
  font-size: 1.3rem;
  font-weight: 900;
  padding: 4px 12px;
  border-radius: 6px;
}

/* Die pip display */
.die-pips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 40px;
  height: 40px;
  gap: 2px;
  padding: 3px;
}

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: transparent;
}

.pip.filled {
  background: #c0392b;
}

/* Active Bets Bar */
.bets-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.active-bets-bar {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border-radius: 6px;
  padding: 10px;
}

.active-bets-bar h3 {
  font-size: 0.8rem;
  color: var(--gold);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.active-bets-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
  align-items: center;
}

.active-bets-list .empty-state {
  padding: 0;
  margin: 0;
  font-size: 0.75rem;
  text-align: left;
}

.active-bet-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-dark);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  border: 1px solid #3a4a6a;
  cursor: default;
  transition: border-color 0.15s;
}

.active-bet-tag:hover {
  border-color: var(--gold);
}

.active-bet-tag .bet-name {
  color: var(--text);
}

.active-bet-tag .bet-amount {
  color: var(--gold);
  font-weight: 700;
}

.press-badge {
  font-size: 0.65rem;
  color: #27ae60;
  font-weight: 600;
  margin-left: 2px;
}

/* Step Bets Placed */
.step-bets-bar {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border-radius: 6px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid rgba(41, 128, 185, 0.3);
}

.step-bets-bar h3 {
  font-size: 0.8rem;
  color: var(--blue);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.step-bets-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 26px;
  justify-content: center;
}

.step-bets-list .empty-state {
  padding: 0;
  margin: 0;
  font-size: 0.75rem;
  text-align: left;
}

.step-bet-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 5px 10px;
  background: var(--bg-dark);
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: default;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}

.step-bet-item:hover {
  border-color: var(--gold);
}

.step-bet-item .step-bet-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  flex-shrink: 0;
}

.step-bet-item .step-bet-type {
  color: var(--text-bright);
  font-weight: 600;
}

.step-bet-item .step-bet-amount {
  color: var(--gold);
  font-weight: 700;
}

.step-bet-item .step-bet-rule {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-left: auto;
}

.step-bet-drawdown .step-bet-dot {
  background: #e74c3c;
}

.step-bet-drawdown .step-bet-amount {
  color: #e74c3c;
}

.roll-outcome-bar {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border-radius: 6px;
  padding: 10px;
  border: 1px solid rgba(212,168,67,0.3);
}

.roll-outcome-bar h3 {
  font-size: 0.8rem;
  color: var(--gold);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.roll-outcome-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 26px;
  justify-content: center;
}

.roll-outcome-list .empty-state {
  padding: 0;
  margin: 0;
  font-size: 0.75rem;
  text-align: left;
}

.roll-outcome-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.15);
  font-size: 0.8rem;
}

.roll-outcome-item.outcome-win {
  border-color: rgba(39,174,96,0.3);
}

.roll-outcome-item.outcome-lose {
  border-color: rgba(231,76,60,0.3);
}

.roll-outcome-item .outcome-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.outcome-win .outcome-dot { background: #27ae60; }
.outcome-lose .outcome-dot { background: #e74c3c; }
.outcome-push .outcome-dot { background: #f39c12; }
.outcome-move .outcome-dot { background: var(--blue); }

.roll-outcome-item .outcome-bet {
  color: var(--text-bright);
  font-weight: 600;
}

.roll-outcome-item .outcome-amount {
  font-weight: 700;
}

.outcome-win .outcome-amount { color: #27ae60; }
.outcome-lose .outcome-amount { color: #e74c3c; }
.outcome-push .outcome-amount { color: #f39c12; }
.outcome-move .outcome-amount { color: var(--blue); }

.roll-outcome-item .outcome-detail {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-left: auto;
}

.roll-outcome-summary {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px 2px;
  font-size: 0.75rem;
  font-weight: 700;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin-top: 4px;
}

.step-bet-landed {
  color: var(--gold);
  font-weight: 700;
}

.step-bet-info-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--text-muted);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: all 0.15s;
}

.step-bet-info-btn:hover,
.step-bet-info-btn.active {
  border-color: var(--blue);
  color: var(--blue);
  background: rgba(41, 128, 185, 0.15);
}

.step-bet-detail {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  border-left: 2px solid var(--blue);
}

.step-bet-detail ul {
  margin: 0;
  padding: 0 0 0 14px;
  list-style: none;
}

.step-bet-detail li {
  font-size: 0.7rem;
  color: var(--text);
  padding: 1px 0;
  position: relative;
}

.step-bet-detail li::before {
  content: '\2713';
  color: #27ae60;
  font-weight: 700;
  position: absolute;
  left: -14px;
}

/* Board highlight for hovered step bet */
.table-cell.step-highlight {
  box-shadow: inset 0 0 16px rgba(41, 128, 185, 0.6), 0 0 8px rgba(41, 128, 185, 0.4);
  border-color: var(--blue);
}

/* Bottom Charts Row */
.bottom-charts-row {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-shrink: 0;
}
.bottom-chart-bankroll,
.bottom-chart-distribution {
  display: flex;
  flex-direction: column;
}
.bottom-chart-bankroll canvas,
.bottom-chart-distribution canvas {
  flex: 1;
  min-height: 0;
}
.bottom-chart-bankroll {
  flex: 1;
  min-width: 0;
}
.bottom-chart-distribution {
  width: 250px;
  flex-shrink: 0;
}
.bottom-chart-performance {
  width: 250px;
  flex-shrink: 0;
}

/* Results Feed (in right panel) */
.panel-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-log .results-feed {
  flex: 1;
  min-height: 0;
}
.results-feed {
  background: var(--bg-dark);
  border-radius: 4px;
  padding: 10px;
  overflow-y: scroll;
  font-size: 0.8rem;
}

.result-entry {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  gap: 8px;
  align-items: center;
}

.result-entry:last-child { border-bottom: none; }

.result-roll-num {
  color: var(--text-muted);
  font-size: 0.7rem;
  min-width: 30px;
}

.result-roll-link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.result-roll-link:hover {
  color: var(--gold);
}

.result-win { color: var(--win-green); }
.result-lose { color: var(--lose-red); }
.result-push { color: var(--push-yellow); }
.result-info { color: var(--text-muted); }

/* Roll History */
.roll-history {
  flex: 1;
  min-height: 0;
  overflow-y: scroll;
  font-size: 0.8rem;
}

.history-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}

.history-entry:hover {
  background: rgba(255,255,255,0.06);
}

.history-entry.history-selected {
  background: rgba(41, 128, 185, 0.25);
  outline: 1px solid var(--blue);
}

.history-num {
  color: var(--text-muted);
  font-size: 0.7rem;
  min-width: 24px;
}

.history-dice {
  display: flex;
  gap: 2px;
}

.history-die {
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 3px;
  color: #222;
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-total {
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.history-total.seven { color: var(--lose-red); }
.history-total.point-hit { color: var(--win-green); }
.history-total.natural { color: var(--gold); }

.history-phase {
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
}

.history-bankroll {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}

.history-fork-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: all 0.15s;
}

.history-entry:hover .history-fork-btn {
  opacity: 1;
}

.history-fork-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(241,196,15,0.15);
}

/* Replay Mode */
#replay-banner {
  display: none;
  background: linear-gradient(135deg, rgba(41,128,185,0.3), rgba(41,128,185,0.15));
  border: 1px solid var(--blue);
  border-radius: 8px;
  padding: 8px 16px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}

#replay-banner button {
  padding: 4px 12px;
  font-size: 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: white;
  cursor: pointer;
  font-weight: 600;
}

#replay-banner button:hover {
  background: #2471a3;
}

#no-rules-warning {
  display: none;
  background: linear-gradient(135deg, rgba(241,196,15,0.3), rgba(241,196,15,0.15));
  border: 1px solid #f1c40f;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #f1c40f;
  text-align: center;
  animation: flash-warning 0.3s ease-in-out 2;
}

@keyframes flash-warning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#bust-banner {
  display: none;
  background: linear-gradient(135deg, rgba(231,76,60,0.3), rgba(231,76,60,0.15));
  border: 1px solid #e74c3c;
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #e74c3c;
  text-align: center;
}

.replay-win {
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.7), inset 0 0 12px rgba(39, 174, 96, 0.3) !important;
  position: relative;
}

.replay-lose {
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.7), inset 0 0 12px rgba(231, 76, 60, 0.3) !important;
  position: relative;
}

body.replay-mode .dice-container {
  opacity: 0.9;
}

/* Animated chips for win/loss */
.anim-chip {
  position: absolute;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 100;
  transform: translate(-50%, -50%) scale(1);
  transition: left 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              top 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.6s ease,
              transform 0.6s ease;
  white-space: nowrap;
}

.anim-chip-move {
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              top 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.anim-chip-move .bet-chip {
  font-size: 0.65rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.anim-chip-win {
  background: var(--win-green);
  color: white;
  box-shadow: 0 0 10px rgba(39, 174, 96, 0.6);
}

.anim-chip-lose {
  background: var(--lose-red);
  color: white;
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.6);
}

/* Strategy Rules */
.strategy-rules {
  margin-bottom: 8px;
  max-height: 250px;
  overflow-y: auto;
}

.rule-item {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 0.78rem;
  transition: opacity 0.15s, border-color 0.15s;
  border: 1px solid transparent;
}

.rule-item.disabled {
  opacity: 0.4;
}

.rule-item.dragging {
  opacity: 0.4;
}

.rule-item.drag-over {
  border-color: var(--gold);
}

.rule-item.editing {
  border-color: var(--gold);
}

.rule-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.rule-right {
  flex: 1;
  min-width: 0;
}

.rule-inline-edit {
  padding-top: 8px;
}

.rule-inline-edit .control-group {
  margin-bottom: 8px;
}

.rule-inline-edit label {
  font-size: 0.72rem;
}

.rule-inline-edit input[type="text"],
.rule-inline-edit input[type="number"],
.rule-inline-edit select {
  width: 100%;
  box-sizing: border-box;
}

.rule-name {
  color: var(--text);
  font-weight: 500;
  margin-bottom: 3px;
  word-break: break-word;
}

.rule-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.rule-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.75rem;
  user-select: none;
  padding: 0 2px;
}

.rule-drag-handle:active {
  cursor: grabbing;
}

.rule-priority {
  color: var(--text-muted);
  font-size: 0.65rem;
}

.rule-trigger-badge {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 8px;
  background: rgba(41, 128, 185, 0.3);
  color: var(--blue);
}

.rule-controls {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.rule-controls button {
  padding: 2px 5px;
  font-size: 0.65rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 2px;
}
.rule-controls button:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

/* Rule Builder */
.rule-builder {
  background: var(--bg-dark);
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
  border: 1px solid #3a4a6a;
}

/* Condition Rows */
.condition-row {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
}

.condition-row select,
.condition-row input[type="number"] {
  padding: 4px 6px;
  border: 1px solid #3a4a6a;
  border-radius: 4px;
  background: var(--bg-dark);
  color: var(--text);
  font-size: 0.78rem;
}

.condition-row .cond-type {
  flex: 1;
  min-width: 0;
}

.condition-row .cond-bet-value,
.condition-row .cond-point-value {
  width: 100px;
}

.condition-row .cond-num-value {
  width: 70px;
}

.condition-row .cond-bet-count-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.condition-row .cond-bet-count-type {
  width: 100px;
}

.condition-row .cond-bet-count-label {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.condition-row .cond-bet-count-max {
  width: 50px;
}

.btn-cond-remove {
  padding: 2px 6px;
  font-size: 0.85rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 2px;
  line-height: 1;
}
.btn-cond-remove:hover {
  background: rgba(231, 76, 60, 0.3);
  color: var(--lose-red);
}

/* Preset Description */
.strategy-name-wrapper {
  position: relative;
}

.strategy-name-wrapper input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #3a4a6a;
  border-radius: 4px;
  background: var(--bg-dark);
  color: var(--text-bright);
  font-size: 0.85rem;
  box-sizing: border-box;
}

.strategy-name-wrapper input:focus {
  border-color: var(--gold);
  outline: none;
}

.preset-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid #3a4a6a;
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.preset-suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(58,74,106,0.3);
}

.preset-suggestion-item:last-child {
  border-bottom: none;
}

.preset-suggestion-item:hover,
.preset-suggestion-item.active {
  background: rgba(212,168,67,0.12);
}

.preset-suggestion-name {
  color: var(--text-bright);
  font-size: 0.85rem;
  font-weight: 600;
}

.preset-suggestion-desc {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-top: 2px;
}

.preset-suggestion-item mark {
  background: rgba(212,168,67,0.3);
  color: var(--gold);
  border-radius: 2px;
  padding: 0 1px;
}

.preset-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 6px;
  font-style: italic;
  min-height: 1em;
}


/* Strategy Stats */
.strategy-stats {
  font-size: 0.8rem;
}

.strat-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.strat-stat-label { color: var(--text-muted); }
.strat-stat-value { color: var(--text); font-weight: 600; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--gold);
  border-radius: 10px;
  max-width: 800px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.modal-sm { max-width: 500px; }
.modal-summary { max-width: 640px; }
.modal-history { max-width: 700px; }
.modal-strategy-expanded { max-width: 900px; max-height: 90vh; }

.modal-strategy-expanded .strategy-rules {
  max-height: 400px;
}

.modal-strategy-expanded .rule-builder {
  max-height: 60vh;
  overflow-y: auto;
}

.h2-actions {
  float: right;
  display: inline-flex;
  gap: 4px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  vertical-align: middle;
  line-height: 1;
}

.btn-icon:hover {
  color: var(--text-bright);
  border-color: var(--text-bright);
}

/* Batch Summary */
.batch-aggregate {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  margin-bottom: 16px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
}

.batch-stat {
  flex: 1 1 calc(33.33% - 8px);
  min-width: 100px;
  text-align: center;
  padding: 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
}

.batch-stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.batch-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-light);
}

.batch-stat-value.win { color: #2ecc71; }
.batch-stat-value.lose { color: #e74c3c; }

.history-entry-num {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 28px;
}

/* Simulation History */
.history-group {
  margin-bottom: 16px;
}

.history-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.history-group-name {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
}

.history-group-hash {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: monospace;
}

.history-group-count {
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-left: auto;
}

.history-group-avg {
  font-weight: 700;
  font-size: 0.8rem;
}

.history-group-avg.win { color: #27ae60; }
.history-group-avg.lose { color: #e74c3c; }
.history-group-avg.neutral { color: var(--text-muted); }

.history-group-entries {
  background: rgba(0,0,0,0.15);
  border-radius: 0 0 6px 6px;
}

.history-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.history-entry:last-child {
  border-bottom: none;
}

.history-entry:hover {
  background: rgba(255,255,255,0.05);
}

.history-entry-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-entry-result {
  font-weight: 700;
  font-size: 0.9rem;
}

.history-entry-result.win { color: #27ae60; }
.history-entry-result.lose { color: #e74c3c; }
.history-entry-result.neutral { color: var(--text-muted); }

.history-entry-detail {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.history-entry-date {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.summary-section {
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.05);
}

.summary-section.full-width {
  grid-column: 1 / -1;
}

.summary-section h3 {
  font-size: 0.75rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(212,168,67,0.2);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 0.8rem;
}

.summary-label {
  color: var(--text-muted);
}

.summary-value {
  color: var(--text-bright);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary-value.win { color: #27ae60; }
.summary-value.lose { color: #e74c3c; }
.summary-value.neutral { color: var(--text-muted); }

.summary-headline {
  text-align: center;
  padding: 12px 0 16px;
}

.summary-headline .result-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.summary-headline .result-amount {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 4px;
}

.summary-headline .result-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.summary-rule-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 0.75rem;
}

.summary-rule-name {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-rule-stats {
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 8px;
}

.summary-bust-label {
  display: inline-block;
  background: rgba(231,76,60,0.2);
  color: #e74c3c;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 8px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid #2a3a5a;
}

.modal-header h2 {
  color: var(--gold);
  font-size: 1.1rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: white; }

.modal-body {
  padding: 20px;
}

.modal-body textarea {
  width: 100%;
  background: var(--bg-dark);
  color: var(--text);
  border: 1px solid #3a4a6a;
  border-radius: 4px;
  padding: 10px;
  font-family: monospace;
  font-size: 0.8rem;
  margin-bottom: 10px;
  resize: vertical;
}

/* Payout Table */
.payout-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.payout-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 2px solid var(--gold);
  color: var(--gold);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.payout-table td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.payout-table tr:hover td {
  background: rgba(255,255,255,0.03);
}

.payout-bet-name { color: var(--text-bright); font-weight: 600; }
.payout-pays { color: var(--gold); font-weight: 600; }
.payout-edge { color: var(--lose-red); }
.payout-edge.low { color: var(--win-green); }
.payout-desc { color: var(--text-muted); font-size: 0.75rem; }

/* Help Content */
.help-content h3 {
  color: var(--gold);
  margin: 16px 0 8px;
  font-size: 1rem;
}

.help-content h3:first-child { margin-top: 0; }

.help-content h4 {
  color: var(--text-bright);
  margin: 10px 0 4px;
  font-size: 0.9rem;
}

.help-content p, .help-content li {
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.5;
}

.help-content ul, .help-content ol {
  padding-left: 20px;
  margin: 6px 0;
}

/* Empty States */
.empty-state {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 12px;
  font-style: italic;
}

/* Bankroll Chart */
canvas {
  width: 100% !important;
  background: var(--bg-dark);
  border-radius: 4px;
}

/* Instant Tooltips */
.tooltip {
  position: relative;
}
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: var(--text-bright);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0s;
  z-index: 100;
}
.tooltip:hover::after {
  opacity: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: #3a4a6a;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #4a5a7a;
}

/* Responsive */
@media (max-width: 1200px) {
  .main-layout {
    grid-template-columns: 260px 1fr 260px;
  }
  .bottom-chart-distribution {
    width: 220px;
  }
  .bottom-chart-performance {
    width: 220px;
  }
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .left-panel, .right-panel {
    border: none;
    border-bottom: 1px solid #2a3a5a;
  }

  .craps-table {
    min-height: 280px;
  }

  .bottom-charts-row {
    flex-direction: column;
  }
  .bottom-chart-distribution,
  .bottom-chart-performance {
    width: 100%;
  }
}

/* Highlight last roll number */
.table-cell.highlight-roll {
  animation: cellFlash 0.6s ease-out;
}

.point-cell.highlight-roll {
  animation: cellFlashPoint 0.6s ease-out;
}

@keyframes cellFlash {
  0% { background: rgba(255, 255, 255, 0.3); box-shadow: inset 0 0 25px rgba(255, 255, 255, 0.5), 0 0 15px rgba(212, 168, 67, 0.6); }
  100% { background: transparent; box-shadow: none; }
}

@keyframes cellFlashPoint {
  0% { background: rgba(255, 255, 255, 0.35); box-shadow: inset 0 0 25px rgba(255, 255, 255, 0.5), 0 0 15px rgba(212, 168, 67, 0.8); border-color: white; }
  100% { background: rgba(255,255,255,0.05); box-shadow: none; }
}

/* Table cell active bet glow */
.table-cell.has-bet {
  border-color: var(--gold);
}
