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

.plinko-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);
}

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

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

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

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

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

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

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

.plinko-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;
}

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

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

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

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

.plinko-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;
}

.plinko-body .live-stats-header h2 span,
.plinko-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;
}

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

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

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

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

.plinko-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;
}

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

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

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

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

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

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

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

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

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

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

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

.plinko-stage {
  min-width: 0;
  display: grid;
  gap: 0.9rem;
  padding: 0.9rem;
  background: #0b1c28;
  border-radius: 0 0.35rem 0.35rem 0;
}

.plinko-bet-panel,
.plinko-board-panel,
.fairness-panel {
  border: 0;
  box-shadow: none;
}

.plinko-bet-panel {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 0.85rem;
  padding: 0.85rem;
  background: transparent;
}

.plinko-bet-panel .control-label {
  margin-bottom: 0;
}

.plinko-bet-panel select,
.plinko-fairness-grid input,
.plinko-bet-panel input {
  min-height: 2.55rem;
  border-radius: 0.4rem;
  border: 1px solid #3d5b6e;
  background: #0b1c28;
  color: #fff;
  font-weight: 850;
}

.plinko-bet-panel input[type="range"] {
  accent-color: #2fe6b6;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: #132c39;
}

.segmented button {
  min-height: 2.35rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #b6c6d1;
  font-weight: 900;
}

.segmented button.active {
  background: #496a7c;
  color: #fff;
}

.plinko-control-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.plinko-control-metrics > div,
.plinko-result-grid > div {
  min-width: 0;
  padding: 0.75rem;
  border-radius: 0.45rem;
  background: #18303d;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.plinko-control-metrics strong,
.plinko-result-grid strong {
  display: block;
  margin-top: 0.2rem;
  color: #fff;
  font-size: 1.03rem;
}

.plinko-body .bet-action {
  width: 100%;
  margin: 0;
  background: #25c89a;
  color: #03150f;
  font-weight: 950;
}

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

.mode-panel[hidden],
.auto-advanced[hidden] {
  display: none;
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: #c4d8e5;
  font-size: 0.84rem;
  font-weight: 850;
}

.custom-switch-row input {
  position: absolute;
  right: 0;
  opacity: 0;
}

.switch-control {
  position: relative;
  flex: 0 0 auto;
  width: 2.55rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #496a7c;
  border: 1px solid #5d7a8d;
}

.switch-control::before {
  content: "";
  position: absolute;
  top: 0.14rem;
  left: 0.15rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #dbe9f0;
  transition: transform 0.14s ease;
}

.custom-switch-row input:checked + .switch-control {
  background: #1f7ae0;
  border-color: #1f7ae0;
}

.custom-switch-row input:checked + .switch-control::before {
  transform: translateX(1.15rem);
}

.auto-advanced {
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: #18303d;
}

.auto-rule {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  padding: 0;
  border: 0;
}

.auto-rule legend {
  margin-bottom: 0.35rem;
  color: #9fd7f3;
  font-size: 0.86rem;
  font-weight: 900;
}

.auto-rule-row {
  display: grid;
  grid-template-columns: 4.4rem 1fr 5.6rem;
  gap: 0.35rem;
}

.rule-choice {
  min-width: 0;
  min-height: 2.25rem;
  border: 0;
  border-radius: 0.35rem;
  background: #496a7c;
  color: #fff;
  font-weight: 900;
  font-size: 0.78rem;
}

.rule-choice.active {
  background: #25c89a;
  color: #03150f;
}

.auto-rule-row label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-radius: 0.35rem;
  background: #0b1c28;
  border: 1px solid #3d5b6e;
}

.auto-rule-row input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
}

.auto-rule-row span {
  padding-right: 0.4rem;
  color: #c4d8e5;
}

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

.plinko-note {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.9rem;
  padding: 0.85rem;
  border-radius: 0.5rem;
  background: #18303d;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.plinko-note strong {
  color: #9fd7f3;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.plinko-note span {
  color: #b9d9ea;
  font-size: 0.82rem;
  line-height: 1.35;
}

.plinko-board-panel {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  background:
    radial-gradient(circle at 72% 18%, rgba(47, 230, 182, 0.16), transparent 30rem),
    linear-gradient(180deg, #0d2532, #091821);
}

.plinko-canvas-wrap {
  position: relative;
  min-height: 28rem;
  border-radius: 0.55rem;
  background:
    linear-gradient(90deg, transparent 0 45%, rgba(75, 169, 225, 0.08) 45% 55%, transparent 55%),
    #071720;
  border: 1px solid rgba(159, 215, 243, 0.14);
  overflow: hidden;
}

#plinkoCanvas {
  display: block;
  width: 100%;
  height: min(36rem, 58vw);
  min-height: 28rem;
}

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

#routeMetric {
  overflow-wrap: anywhere;
}

.plinko-fairness-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.plinko-fairness-grid label {
  display: grid;
  gap: 0.35rem;
  color: #9fd7f3;
  font-size: 0.84rem;
  font-weight: 850;
}

.seed-hash-box,
.button-row {
  grid-column: span 2;
}

.seed-hash-box {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.75rem;
  border-radius: 0.45rem;
  background: #132c39;
}

.seed-hash-box code {
  overflow-wrap: anywhere;
  color: #fff;
}

.history-wrap {
  margin-top: 0.9rem;
}

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

.profit-negative {
  color: #ff5b74;
}

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

  .plinko-layout {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .plinko-layout.stats-open {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 620px) {
  .plinko-control-metrics,
  .plinko-result-grid,
  .plinko-fairness-grid,
  .auto-rule-row,
  .auto-pacing {
    grid-template-columns: 1fr;
  }

  .seed-hash-box,
  .button-row {
    grid-column: auto;
  }
}
