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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.keno-stage > *,
.keno-board-panel,
.fairness-panel,
.history-wrap {
  min-width: 0;
  max-width: 100%;
}

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

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

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

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

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

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

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

.keno-body .bet-action {
  width: 100%;
  margin: 0;
  background: #1f7ae0;
  color: #fff;
  font-weight: 950;
}

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

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

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

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

.keno-board-panel {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  background:
    radial-gradient(circle at 46% 35%, rgba(159, 46, 255, 0.14), transparent 25rem),
    linear-gradient(180deg, #0d2532, #071720);
}

.keno-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: clamp(0.35rem, 1vw, 0.7rem);
}

.keno-tile {
  position: relative;
  min-width: 0;
  aspect-ratio: 1 / 0.82;
  border: 0;
  border-radius: 0.45rem;
  background: #304c5d;
  color: #f4f8fb;
  font-size: clamp(1rem, 2.1vw, 1.45rem);
  font-weight: 950;
  box-shadow:
    inset 0 -0.28rem 0 rgba(0, 0, 0, 0.17),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.keno-tile:hover {
  transform: translateY(-1px);
}

.keno-tile.selected {
  background: linear-gradient(180deg, #9b42e8, #9013f6);
  color: #fff;
  box-shadow:
    inset 0 -0.28rem 0 rgba(82, 0, 128, 0.38),
    0 0 0 0.12rem rgba(175, 75, 255, 0.35);
}

.keno-tile.drawn {
  background: #071720;
  color: #cf1b56;
  box-shadow:
    inset 0 -0.28rem 0 rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.keno-tile.hit {
  background: linear-gradient(180deg, #32f953, #15ca31);
  color: #032407;
  box-shadow:
    inset 0 -0.28rem 0 rgba(4, 86, 16, 0.3),
    0 0 0 0.18rem rgba(139, 255, 96, 0.35),
    0 0 1.4rem rgba(48, 249, 83, 0.5);
}

.keno-tile.hit::after {
  content: "";
  position: absolute;
  inset: 0.45rem;
  border: 2px solid rgba(3, 36, 7, 0.22);
  border-radius: 0.35rem;
}

.keno-payout-table {
  display: grid;
  grid-template-columns: repeat(var(--payout-cols, 1), minmax(4.4rem, 1fr));
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.payout-cell {
  display: grid;
  grid-template-rows: 2.3rem 2.3rem;
  min-width: 4.4rem;
  border-radius: 0.35rem;
  overflow: hidden;
  background: #2c4859;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.payout-cell.active {
  box-shadow: 0 0 0 0.12rem rgba(47, 230, 182, 0.65);
}

.payout-cell strong,
.payout-cell span {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0 0.35rem;
  overflow-wrap: anywhere;
  text-align: center;
}

.payout-cell strong {
  color: #fff;
  font-size: 0.82rem;
}

.payout-cell span {
  background: rgba(255, 255, 255, 0.05);
  color: #c9dce8;
  font-size: 0.78rem;
  font-weight: 900;
}

.payout-cell.active span {
  color: #14f46a;
}

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

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

.keno-result-grid strong {
  display: block;
  margin-top: 0.2rem;
  color: #fff;
  font-size: 1.03rem;
  overflow-wrap: anywhere;
}

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

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

.keno-body pre {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.profit-negative {
  color: #ff5b74;
}

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

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

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

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

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

@media (max-width: 620px) {
  .keno-board {
    gap: 0.3rem;
  }

  .keno-tile {
    border-radius: 0.35rem;
    font-size: 0.9rem;
  }

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

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