.crash-body {
  min-height: 100vh;
  background: #0c1f2a;
}

.crash-body [hidden] {
  display: none !important;
}

.crash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
  padding: 0.75rem max(1rem, calc((100vw - 1220px) / 2));
  background: #132c39;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.crash-topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.crash-topbar h1,
.crash-topbar p {
  margin: 0;
}

.crash-topbar h1 {
  font-size: 1.35rem;
  line-height: 1.1;
}

.crash-topbar p {
  color: var(--muted);
  font-size: 0.82rem;
}

.crash-topbar .status-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.crash-topbar .status-strip > div {
  padding: 0.45rem 0.8rem;
  border-radius: 0.45rem;
  background: #0f2532;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.crash-topbar .button {
  min-height: 2.75rem;
  border-radius: 0.45rem;
}

.crash-layout {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr);
  gap: 0;
  max-width: 1220px;
  min-height: calc(100vh - 4.25rem);
  margin: 0 auto;
  padding: 1.25rem 0;
}

.crash-layout.stats-open {
  grid-template-columns: 18rem 18rem minmax(0, 1fr);
}

.crash-body .live-stats-drawer {
  display: none;
  min-height: 100%;
  min-width: 18rem;
  padding: 1rem;
  background: #203946;
  border-radius: 0.35rem 0 0 0.35rem;
}

.crash-layout.stats-open .live-stats-drawer {
  display: block;
}

.crash-body .live-stats-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2rem;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.crash-body .live-stats-header h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
  white-space: nowrap;
}

.crash-body .live-stats-header h2 span,
.crash-body .credit-dot {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 0.3rem;
  background: #26cfa1;
  color: #03150f;
  font-size: 0.58rem;
  font-weight: 950;
}

.crash-body .credit-dot {
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  font-size: 0.42rem;
  vertical-align: 0.12rem;
}

.crash-body .live-stats-header .icon-button,
.crash-body .stats-filter-row .icon-button {
  min-width: 2rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1rem;
}

.crash-body .stats-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2rem;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.crash-body .stats-filter-row select {
  width: 100%;
  min-width: 0;
}

.crash-body .live-stats-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 0.85rem;
  margin-bottom: 0.85rem;
  border-radius: 0.45rem;
  background: #18303d;
}

.crash-body .live-stats-metrics > div {
  min-width: 0;
  min-height: 3.5rem;
  padding: 0.2rem 0.7rem;
}

.crash-body .live-stats-metrics > div:nth-child(odd) {
  border-right: 1px solid #3d5b6e;
}

.crash-body .live-stats-metrics strong {
  display: inline-block;
  max-width: 100%;
  margin-top: 0.05rem;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.crash-body .stats-chart {
  height: 13.75rem;
  padding: 0.8rem;
  border-radius: 0.45rem;
  background: #102532;
  overflow: hidden;
}

.crash-body .stats-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.crash-body .chart-fill {
  fill: rgba(20, 244, 106, 0.22);
}

.crash-body .chart-loss-fill {
  fill: rgba(255, 40, 84, 0.24);
}

.crash-body .chart-line {
  fill: none;
  stroke: #14f46a;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crash-body .chart-loss-line {
  fill: none;
  stroke: #ff2854;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crash-body .chart-zero {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 2;
}

.crash-controls {
  display: flex;
  flex-direction: column;
  background: #203946;
  border-radius: 0.35rem 0 0 0.35rem;
}

.crash-bet-panel {
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.crash-bet-panel .segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 0.25rem;
  border-radius: 999px;
  background: #0d2330;
}

.crash-bet-panel .segmented button {
  min-height: 2.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #c8dce8;
  font-weight: 800;
  cursor: pointer;
}

.crash-bet-panel .segmented button.active {
  background: #6f8fa1;
  color: #061924;
}

.crash-bet-panel input,
.crash-bet-panel select,
.crash-fairness-grid input,
.stats-filter-row select {
  width: 100%;
  min-height: 2.6rem;
  border: 1px solid #335368;
  border-radius: 0.45rem;
  padding: 0.65rem 0.75rem;
  background: #0d202b;
  color: #f3fbff;
  font-weight: 800;
}

.mode-panel,
.auto-panel,
.auto-advanced {
  display: grid;
  gap: 0.7rem;
}

.bet-action {
  width: 100%;
  min-height: 2.75rem;
  border-radius: 0.45rem;
  font-weight: 900;
}

.auto-rule {
  margin: 0;
  padding: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.45rem;
}

.auto-rule legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.auto-rule-row {
  display: grid;
  grid-template-columns: 4.4rem minmax(0, 1fr) 5.8rem;
  gap: 0.35rem;
  align-items: center;
}

.auto-rule-row button,
.auto-rule-row label {
  min-width: 0;
  min-height: 2.35rem;
  border-radius: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #0f2532;
  color: #dcecf4;
  font-weight: 800;
}

.auto-rule-row button {
  cursor: pointer;
}

.auto-rule-row button.active {
  background: #6f8fa1;
  color: #061924;
}

.auto-rule-row label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.4rem;
  color: #e9f5fb;
}

.auto-rule-row input {
  width: 100%;
  min-width: 0;
  min-height: 2rem;
  padding: 0.35rem 0.2rem;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-weight: 900;
}

.auto-rule-row span {
  padding-right: 0.15rem;
  color: #d9eaf2;
  font-weight: 900;
}

.auto-pacing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
}

.custom-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.6rem;
}

.custom-switch-row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-control {
  position: relative;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #39566a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.switch-control::after {
  content: "";
  position: absolute;
  top: 0.18rem;
  left: 0.18rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #9eb5c3;
  transition: transform 0.16s ease, background 0.16s ease;
}

.custom-switch-row input:checked + .switch-control {
  background: #2778d8;
}

.custom-switch-row input:checked + .switch-control::after {
  transform: translateX(1.12rem);
  background: #ffffff;
}

.crash-note {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem;
  border-radius: 0.45rem;
  background: #14303e;
  color: #bfd3df;
  font-size: 0.8rem;
  line-height: 1.45;
}

.crash-note strong {
  color: #dff5ff;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.72rem;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.text-button {
  min-height: 2.1rem;
  padding: 0.4rem 0.65rem;
  border: 0;
  border-radius: 0.35rem;
  background: #314d60;
  color: #e3f2f8;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.text-button[aria-pressed="true"] {
  background: #1a8fff;
  color: #ffffff;
}

.crash-stage {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 1rem;
  padding: 0 1.25rem;
}

.crash-stage > * {
  min-width: 0;
}

.crash-game-panel {
  padding: 1rem;
  border-radius: 0.45rem;
  background: #071c27;
}

.recent-results {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 2.1rem;
  margin-bottom: 0.75rem;
}

.recent-chip {
  display: inline-grid;
  place-items: center;
  min-width: 3.4rem;
  min-height: 1.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #263f4f;
  color: #d8eef7;
  font-size: 0.74rem;
  font-weight: 900;
}

.recent-chip.win {
  background: #20d47f;
  color: #041712;
}

.recent-chip.loss {
  background: #344b5a;
  color: #f0f7fb;
}

.crash-graph-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 0.45rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 42%),
    #071d28;
}

.crash-graph {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 8.8;
  min-height: 24rem;
}

.grid-lines line {
  stroke: rgba(167, 205, 226, 0.13);
  stroke-width: 2;
}

.crash-fill {
  fill: rgba(255, 158, 0, 0.75);
}

.crash-line {
  fill: none;
  stroke: #fff5c4;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crash-dot {
  fill: #ffd23c;
  stroke: #fff7c7;
  stroke-width: 4;
}

.graph-multiplier {
  fill: #ffffff;
  font-size: 2.7rem;
  font-weight: 950;
}

.graph-status {
  fill: #c9dae4;
  font-size: 1rem;
  font-weight: 850;
}

.crash-game-panel.crashed .graph-multiplier,
.crash-game-panel.crashed .graph-status {
  fill: #ff315b;
}

.crash-game-panel.cashout .graph-status {
  fill: #2ff0a4;
}

.axis-label {
  fill: #8ba8b8;
  font-size: 0.78rem;
  font-weight: 800;
}

.crash-result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.crash-result-grid > div,
.fairness-panel {
  padding: 1rem;
  border-radius: 0.45rem;
  background: #132d3a;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.crash-result-grid strong {
  display: block;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
  font-size: 1.15rem;
}

.fairness-panel summary {
  cursor: pointer;
  font-weight: 900;
}

.crash-fairness-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.crash-fairness-grid label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-weight: 850;
}

.seed-hash-box {
  display: grid;
  gap: 0.35rem;
}

.seed-hash-box code {
  display: block;
  min-height: 2.6rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.45rem;
  background: #0d202b;
  border: 1px solid #335368;
  color: #e6f4fb;
  overflow-wrap: anywhere;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-content: start;
}

#resultOutput {
  min-height: 12rem;
  max-height: 31rem;
  overflow: auto;
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 0.45rem;
  background: #091c27;
  color: #e5f7ff;
  font-size: 0.78rem;
  line-height: 1.45;
}

.history-wrap {
  overflow-x: auto;
}

.history-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.history-wrap th,
.history-wrap td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: left;
  white-space: nowrap;
}

.profit-positive {
  color: #14f46a;
}

.profit-negative {
  color: #ff5776;
}

.info-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(4, 13, 18, 0.72);
}

.info-dialog {
  width: min(36rem, 100%);
  border-radius: 0.55rem;
  background: #19313e;
  color: #dbeef7;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.35);
}

.info-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.25rem;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
}

.info-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.info-tabs {
  display: flex;
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: 0 auto 0.75rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: #0d2330;
}

.info-tabs button {
  min-width: 8rem;
  min-height: 2.35rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #d6e7ef;
  font-weight: 900;
  cursor: pointer;
}

.info-tabs button.active {
  background: #6f8fa1;
  color: #061924;
}

.info-panel {
  padding: 0 1.25rem 1.25rem;
  line-height: 1.6;
}

.info-panel ol {
  margin: 0;
  padding-left: 1.2rem;
}

.max-list {
  display: grid;
  gap: 0.55rem;
}

.max-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.45rem;
  background: #102734;
}

@media (max-width: 1080px) {
  .crash-topbar,
  .crash-topbar .status-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .crash-topbar .status-strip {
    width: 100%;
  }

  .crash-layout,
  .crash-layout.stats-open {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .crash-body .live-stats-drawer,
  .crash-controls {
    border-radius: 0;
  }

  .crash-bet-panel {
    position: static;
  }

  .crash-stage {
    padding: 1rem;
  }

  .crash-result-grid,
  .crash-fairness-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .crash-topbar {
    padding: 0.75rem;
  }

  .crash-topbar .status-strip > div,
  .crash-topbar .button {
    width: 100%;
  }

  .crash-result-grid,
  .crash-fairness-grid,
  .auto-rule-row,
  .auto-pacing {
    grid-template-columns: 1fr;
  }

  .crash-graph {
    min-height: 18rem;
  }

  .graph-multiplier {
    font-size: 2rem;
  }

  .info-tabs {
    width: calc(100% - 2rem);
  }

  .info-tabs button {
    min-width: 0;
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .switch-control::after {
    transition: none;
  }
}
