:root {
  --bg: #0a0f1a;
  --panel: #0d1422;
  --panel-border: #212c45;
  --input: #1d2433;
  --input-border: #2a3550;
  --text: #f7f8fb;
  --muted: #9eb1ce;
  --green: #4bcb73;
  --red: #f24d4d;
  --purple: #7440ff;
  --purple-bright: #8f58ff;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
  background:
    radial-gradient(1100px 400px at 100% 0%, #11172a 0%, transparent 70%),
    linear-gradient(180deg, #090d16, #080b14 65%);
}

.app-shell {
  width: min(1020px, 94vw);
  margin: 12px auto;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: 1.4rem;
}

.layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 0;
  border: 1px solid #1b253a;
  border-radius: 0;
  min-height: 74vh;
  overflow: hidden;
}

.panel {
  background: #0a101c;
  border-right: 1px solid #1b253a;
  padding: 14px 16px;
}

.results {
  border-right: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.controls-panel {
  padding: 16px;
}

.tab-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #1a2232;
  border-radius: 8px;
  padding: 5px;
  margin-bottom: 16px;
}

.tab {
  border: 0;
  background: transparent;
  color: #c4d1e8;
  font-weight: 600;
  border-radius: 7px;
  padding: 9px 10px;
  cursor: pointer;
}

.tab.active {
  background: linear-gradient(90deg, #6a2ff8, #823cff);
  color: #ffffff;
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
}

.control-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 8px;
}

.control-row-head p {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.control-row-head p:last-child {
  color: #90a7c8;
  font-size: 0.92rem;
}

.control-row-head.compact {
  margin-top: 12px;
}

.info-dot {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #8ea4c4;
  font-size: 0.7rem;
  margin-left: 2px;
}

.bet-input-wrap,
.number-bets-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  background: var(--input);
  border: 1px solid #1f2940;
  border-radius: 8px;
  padding: 6px;
  margin-bottom: 16px;
}

.bet-input-wrap input,
.number-bets-wrap input,
.strategy-row select {
  width: 100%;
  border: 0;
  background: transparent;
  color: #ffffff;
  padding: 8px 10px;
  outline: none;
  font: inherit;
}

.bet-mults {
  display: flex;
  gap: 4px;
}

.mini-btn {
  border: 0;
  border-radius: 6px;
  background: #313b52;
  color: #ffffff;
  font-weight: 700;
  padding: 8px 10px;
  cursor: pointer;
}

.mini-icon {
  min-width: 44px;
  font-size: 1.2rem;
}

.group-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
  font-weight: 600;
}

.readonly-box {
  border: 1px solid #27314b;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  min-height: 46px;
  color: #d8e2f3;
  font-family: "IBM Plex Mono", monospace;
}

.auto-grid {
  border: 1px solid #25314a;
  border-radius: 10px;
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.auto-grid p {
  margin: 0 0 4px;
  font-size: 0.84rem;
  color: #9cb0cd;
}

.auto-grid strong {
  font-weight: 600;
}

.outline-btn,
.cta-btn,
.reset-link {
  width: 100%;
  border-radius: 8px;
  padding: 13px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.outline-btn {
  border: 1px solid #b9c6de;
  background: transparent;
  color: #f0f4ff;
  margin-bottom: 12px;
}

.cta-btn {
  border: 0;
  background: linear-gradient(90deg, #6a2ff8, #823cff);
  color: #ffffff;
  margin-bottom: 12px;
}

.strategy-row {
  position: relative;
  margin-bottom: 10px;
}

.strategy-row select {
  background: var(--input);
  border: 1px solid #1f2940;
  border-radius: 8px;
  appearance: none;
  padding-right: 36px;
}

.strategy-row::after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 11px;
  color: #b8c8e2;
  pointer-events: none;
}

.small-link {
  color: #4bcb73;
  font-size: 0.9rem;
  text-decoration: none;
}

.small-link.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.strategy-row .small-link {
  position: absolute;
  right: 12px;
  top: -22px;
}

.condition-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.condition-chip {
  border: 0;
  border-radius: 7px;
  background: #232d43;
  color: #ffffff;
  min-height: 46px;
  font: inherit;
  font-weight: 700;
}

.hidden-settings {
  display: none;
}

.reset-link {
  border: 0;
  background: transparent;
  color: #9fb2cf;
  font-weight: 600;
  padding: 6px 0 0;
  text-align: left;
}

.metric-field.compact {
  height: 42px;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.metric-field.compact input {
  font-size: 0.95rem;
}

.control-actions-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.control-actions-row .outline-btn {
  margin-bottom: 0;
}

.speed-control {
  margin-top: 12px;
}

.speed-control input[type="range"] {
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 14, 0.78);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(520px, 100%);
  background: #0e1626;
  border: 1px solid #2b3752;
  border-radius: 12px;
  padding: 16px;
}

.modal-card-wide {
  width: min(720px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-head-centered h2 {
  width: 100%;
  text-align: center;
}

.modal-head h2 {
  margin: 0;
}

.save-status {
  margin-left: auto;
  margin-right: 10px;
  font-size: 0.8rem;
  color: #6fe47f;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.save-status.visible {
  opacity: 1;
}

.save-status.error {
  color: #ff6f6f;
}

.modal-subtext {
  margin: 0 0 12px;
  color: #b8c7de;
}

.modal-subtext.centered {
  text-align: center;
}

.modal-actions {
  margin-top: 8px;
}

.modal-inline {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.modal-inline select,
.modal-inline input {
  border: 1px solid #2b3954;
  border-radius: 8px;
  background: #1b2333;
  color: #f7f8fb;
  padding: 10px;
  font: inherit;
}

.editor-placeholder {
  min-height: 220px;
  border: 1px dashed #334560;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #90a4c3;
  background: #182235;
}

#strategyConditionsList {
  max-height: min(62vh, 520px);
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 12px;
}

.condition-block {
  border: 1px solid #34435e;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
}

.condition-head {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  background: #05080f;
  border-bottom: 1px solid #2f3c58;
}

.condition-title {
  padding: 14px 16px;
  font-weight: 700;
  color: #9b79ff;
}

.condition-head-actions {
  display: flex;
}

.condition-head-btn {
  width: 44px;
  border: 0;
  border-left: 1px solid #2f3c58;
  background: #0b111d;
  color: #9cb0cf;
  font: inherit;
  cursor: pointer;
}

.condition-body {
  padding: 14px 16px;
  background: #0e1626;
}

.condition-radio-row {
  display: flex;
  gap: 22px;
  margin-bottom: 12px;
}

.condition-label,
.condition-label-row p {
  margin: 0 0 8px;
  color: #d8e4f6;
}

.condition-label-row {
  display: flex;
  justify-content: space-between;
}

.condition-usd {
  color: #9cb0cd;
}

.condition-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.condition-row:last-of-type {
  grid-template-columns: 1fr 1fr;
}

.condition-field {
  background: #1b2435;
  border: 1px solid #303f5d;
  border-radius: 8px;
  padding: 0;
  color: #eef2fb;
}

.condition-field select,
.condition-field input {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #eef2fb;
  padding: 0 12px;
  font: inherit;
  outline: none;
}

.delete-condition-btn {
  margin-top: 4px;
  border: 0;
  background: transparent;
  color: #ff5d5d;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.condition-body-collapsed {
  background: #0e1626;
  padding: 14px 16px;
}

.collapsed-line {
  margin: 0 0 6px;
  color: #dbe6f7;
}

.accent-text {
  color: #6fe47f;
}

.strategy-editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.strategy-editor-actions .cta-btn,
.strategy-editor-actions .outline-btn {
  margin-bottom: 0;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.toggle-btn {
  border: 1px solid #2b3954;
  border-radius: 8px;
  background: #1b2333;
  color: #d3deef;
  padding: 9px 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.toggle-btn.active {
  background: linear-gradient(90deg, #6a2ff8, #823cff);
  color: #ffffff;
  border-color: #7344ff;
}

.stats-modal {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1100;
}

.stats-modal.hidden {
  display: none;
}

.stats-modal-card {
  position: fixed;
  top: 90px;
  left: 360px;
  width: min(390px, calc(100vw - 20px));
  background: #111a2a;
  border: 1px solid #27344d;
  border-radius: 10px;
  padding: 10px;
  pointer-events: auto;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

.stats-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  cursor: move;
}

.stats-modal-head h2 {
  margin: 0;
  font-size: 0.92rem;
}

.stats-primary-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #1a2436;
  border: 1px solid #2a3954;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}

.stats-primary-cell {
  padding: 10px;
  min-height: 58px;
}

.stats-primary-cell:nth-child(1),
.stats-primary-cell:nth-child(2) {
  border-bottom: 1px solid #334260;
}

.stats-primary-cell:nth-child(odd) {
  border-right: 1px solid #334260;
}

.stats-primary-cell p {
  margin: 0 0 5px;
  color: #9cb0cd;
}

.stats-primary-cell strong {
  font-size: 1.08rem;
  color: #7ce67d;
}

.stats-primary-cell:last-child strong {
  color: #ff6f6f;
}

#statsProfit.loss {
  color: #ff6f6f;
}

.stats-graph-card {
  background: #1a2436;
  border: 1px solid #2a3954;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 10px;
}

.stats-graph-card canvas {
  width: 100%;
  height: 145px;
  display: block;
}

.stats-extra-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stats-extra-item {
  border: 1px solid #31405e;
  border-radius: 8px;
  padding: 8px;
  background: #1a2436;
}

.stats-extra-item p {
  margin: 0 0 3px;
  color: #9cb0cd;
  font-size: 0.78rem;
}

.stats-extra-item strong {
  font-size: 0.94rem;
}

.stats-extra-item.loss strong {
  color: #ff6f6f;
}

.results h2,
.results h3 {
  margin: 0 0 14px;
}

.dice-board {
  flex: 1;
  min-height: 260px;
  display: grid;
  align-content: center;
  gap: 10px;
}

.dice-track-frame {
  border: 6px solid #25324e;
  border-radius: 10px;
  padding: 14px 16px;
  background: #0d1422;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.dice-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  overflow: visible;
  display: flex;
}

.segment-win,
.segment-loss {
  height: 100%;
}

.segment-win {
  background: #54cf71;
  border-radius: 999px 0 0 999px;
}

.segment-loss {
  background: #ea4848;
  border-radius: 0 999px 999px 0;
}

.target-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -55%);
  font-size: 2rem;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.dice-ticks {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  color: #ffffff;
  font-weight: 700;
  font-size: 1.98rem;
}

.dice-ticks span {
  text-align: center;
  position: relative;
  font-size: 1.9rem;
}

.dice-ticks span::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #25324e;
}

.metric-strip {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-box label {
  display: block;
  font-size: 0.96rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.metric-field {
  height: 50px;
  border-radius: 8px;
  background: #1b2333;
  border: 1px solid #25314a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 1.82rem;
  font-family: "IBM Plex Mono", monospace;
}

.metric-field input {
  border: 0;
  background: transparent;
  color: #ffffff;
  width: 100%;
  font: inherit;
  outline: none;
}

.field-icon {
  color: #e3e8f2;
  font-size: 1.6rem;
}

.field-icon-btn {
  border: 0;
  background: transparent;
  color: #e3e8f2;
  font-size: 1.6rem;
  cursor: pointer;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  border: 1px solid #26314b;
  border-radius: 10px;
  padding: 10px;
}

.stat p {
  margin: 0;
}

.stat .label {
  color: var(--muted);
  font-size: 0.8rem;
}

.stat .value {
  margin-top: 2px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.1rem;
}

.table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid #26314b;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid #1e2941;
  text-align: left;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
}

td.win {
  color: var(--green);
}

td.loss {
  color: var(--red);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid #1b253a;
  }

  .results {
    border-bottom: 0;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .control-actions-row {
    grid-template-columns: 1fr;
  }

  .stats-modal-card {
    left: 12px;
    top: 72px;
  }
}
