.snakes-body {
  min-height: 100vh;
  background: #0a1f25;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.snakes-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: #15313a;
}

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

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

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

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

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

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

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

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

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

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

.snakes-controls {
  display: flex;
  flex-direction: column;
  background: #1c3942;
  border-radius: 0.35rem 0 0 0.35rem;
}

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

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

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

.snakes-bet-panel .segmented button.active {
  background: #87a7b2;
  color: #061924;
}

.snakes-bet-panel input,
.snakes-bet-panel select,
.verifier-panel input,
.stats-filter-row select {
  width: 100%;
  min-height: 2.6rem;
  border: 1px solid #335b64;
  border-radius: 0.45rem;
  padding: 0.65rem 0.75rem;
  background: #0b2028;
  color: #f3fbff;
}

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

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

.profit-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  min-height: 3.15rem;
  padding: 0.7rem 0.85rem;
  border-radius: 0.45rem;
  background: #15313a;
  color: #c6d8e2;
  font-size: 0.85rem;
}

.profit-card strong {
  color: #ffffff;
}

.auto-panel,
.auto-advanced {
  gap: 0.75rem;
}

.auto-advanced {
  display: grid;
}

.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(6.5rem, 1fr);
  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: #0e2730;
  color: #dcecf4;
  font-weight: 800;
}

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

.auto-rule-row button.active {
  background: #87a7b2;
  color: #061924;
}

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

.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-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: #385d68;
  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;
}

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

.snakes-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: #315261;
  color: #e3f2f8;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

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

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

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

.board-panel {
  position: relative;
  min-width: 0;
  padding: 1rem;
  border-radius: 0.45rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 45% 12%, rgba(45, 213, 132, 0.13), transparent 16rem),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 5rem 100%,
    #081f28;
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.board-head strong {
  display: block;
  margin-top: 0.1rem;
}

.dice-display {
  display: flex;
  gap: 0.35rem;
  min-height: 3rem;
  align-items: center;
}

.die {
  --pip-size: 0.34rem;
  position: relative;
  width: 2.45rem;
  height: 2.45rem;
  border-radius: 0.42rem;
  background: #dce7ef;
  box-shadow: inset 0 -0.18rem 0 rgba(0, 0, 0, 0.18);
}

.die::before {
  content: attr(data-value);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #11212a;
  font-size: 0.85rem;
  font-weight: 950;
}

.die.rolling {
  animation: die-pop 0.34s ease both;
}

.snake-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.board-space {
  min-height: 5.4rem;
  padding: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.45rem;
  background: #153540;
  color: #e6f3f7;
}

.board-space.start {
  background: #244756;
}

.board-space.safe {
  background: #123d35;
  border-color: rgba(37, 216, 132, 0.35);
}

.board-space.snake {
  background: #492034;
  border-color: rgba(255, 70, 112, 0.38);
}

.board-space.active {
  outline: 0.18rem solid #ffc20e;
  outline-offset: -0.18rem;
}

.board-space.passed {
  box-shadow: inset 0 0 0 0.12rem rgba(37, 216, 132, 0.45);
}

.space-index,
.space-kind {
  display: block;
}

.space-index {
  color: #b9d0da;
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.space-value {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.05rem;
  font-weight: 950;
}

.space-kind {
  margin-top: 0.2rem;
  color: #b9d0da;
  font-size: 0.72rem;
  font-weight: 800;
}

.round-banner {
  min-height: 3rem;
  padding: 0.75rem 1rem;
  border-radius: 0.45rem;
  background: rgba(17, 49, 59, 0.95);
  color: #d8edf6;
  text-align: center;
  font-weight: 850;
  box-shadow: 0 0.6rem 1rem rgba(0, 0, 0, 0.18);
}

.round-banner.win {
  background: #0e6f55;
  color: #ffffff;
}

.round-banner.loss {
  background: #95233d;
  color: #ffffff;
}

.roll-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.roll-card {
  min-height: 6.6rem;
  padding: 0.65rem;
  border-radius: 0.5rem;
  background: #132f39;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.roll-card.revealed.safe {
  background: #123d35;
}

.roll-card.revealed.snake {
  background: #51213a;
}

.roll-card.active {
  outline: 0.16rem solid #ffc20e;
  outline-offset: -0.16rem;
}

.roll-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  color: #b9d0da;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.roll-outcome {
  display: block;
  margin-bottom: 0.55rem;
  font-size: 1.05rem;
  font-weight: 950;
}

.roll-dice {
  display: flex;
  gap: 0.25rem;
}

.roll-dice .die {
  width: 1.95rem;
  height: 1.95rem;
  border-radius: 0.34rem;
}

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

.snakes-result-grid > div,
.history-panel,
.verifier-panel {
  padding: 1rem;
  border-radius: 0.45rem;
  background: #12323b;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

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

.verifier-panel {
  color: #d7eaf2;
}

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

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

.verifier-grid code {
  display: block;
  min-height: 2.6rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.45rem;
  background: #0b2028;
  border: 1px solid #335b64;
  color: #e6f4fb;
  overflow-wrap: anywhere;
}

.verifier-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0.9rem 0;
}

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

.history-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

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

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

.history-panel th,
.history-panel 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: #17333c;
  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: #0b2229;
}

.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: #87a7b2;
  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: #0e2831;
}

@keyframes die-pop {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  45% {
    transform: translateY(-0.35rem) rotate(8deg);
  }
  100% {
    transform: translateY(0) rotate(0deg);
  }
}

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

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

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

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

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

  .snakes-stage {
    padding: 1rem;
  }

  .snake-board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .roll-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

  .board-head,
  .auto-pacing {
    align-items: stretch;
    flex-direction: column;
  }

  .snake-board,
  .roll-track,
  .snakes-result-grid,
  .verifier-grid,
  .auto-rule-row,
  .auto-pacing {
    grid-template-columns: 1fr;
  }

  .board-space {
    min-height: 4.25rem;
  }

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

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

@media (prefers-reduced-motion: reduce) {
  .die.rolling {
    animation: none;
  }
}
