:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-strong: #eef3f1;
  --ink: #17211d;
  --muted: #5f6c67;
  --line: #dce5e1;
  --green: #0f8a5f;
  --green-dark: #0a6548;
  --mint: #dff5eb;
  --amber: #cc8a13;
  --amber-soft: #fff3d5;
  --rose: #be3c68;
  --rose-soft: #ffe5ed;
  --teal: #156c75;
  --shadow: 0 18px 50px rgba(20, 35, 30, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, rgba(15, 138, 95, 0.08), transparent 34rem),
    linear-gradient(180deg, #fbfdfc 0%, var(--bg) 45%, #eef3f1 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--green-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.workspace,
.stats-section,
.footer {
  width: min(1180px, 100%);
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(15, 138, 95, 0.32);
  border-radius: 50%;
  background:
    linear-gradient(135deg, rgba(15, 138, 95, 0.18), rgba(204, 138, 19, 0.18)),
    #ffffff;
  box-shadow: 0 10px 26px rgba(15, 138, 95, 0.16);
}

.brand-mark span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #ffffff;
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green-dark);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 2.6vw, 2.5rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
  line-height: 1.15;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.source-chip,
.odds-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  align-items: start;
}

.tool-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.controls-panel,
.results-panel {
  padding: 18px;
}

.panel-heading,
.stats-header,
.board-head,
.mini-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  margin-bottom: 18px;
}

.mini-heading {
  justify-content: flex-start;
  margin-bottom: 14px;
}

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

.control {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.control span strong {
  color: var(--ink);
}

.control select,
.control input[type="number"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

.control select {
  padding: 0 12px;
}

.control input[type="number"] {
  text-align: center;
  font-weight: 850;
}

.range-control {
  grid-column: 1 / -1;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.segment-button,
.number-button,
.icon-button,
.primary-button,
.secondary-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.segment-button {
  min-width: 0;
  min-height: 42px;
  padding: 0 4px;
  font-weight: 850;
}

.segment-button.active {
  border-color: var(--green);
  background: var(--mint);
  color: var(--green-dark);
}

.stepper {
  display: grid;
  grid-template-columns: 44px minmax(58px, 1fr) 44px;
  gap: 6px;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
}

.icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
}

.icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

.board-head {
  margin: 22px 0 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.fixed {
  background: var(--green);
}

.legend-dot.blocked {
  background: var(--rose);
}

.number-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 8px;
}

.number-button {
  position: relative;
  aspect-ratio: 1;
  min-height: 48px;
  padding: 0;
  overflow: hidden;
  font-weight: 900;
}

.number-button:hover,
.segment-button:hover,
.icon-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 138, 95, 0.5);
  box-shadow: 0 10px 22px rgba(20, 35, 30, 0.09);
}

.number-button.fixed {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.number-button.blocked {
  border-color: var(--rose);
  background: var(--rose-soft);
  color: var(--rose);
}

.number-button.hot::after,
.number-button.late::before {
  position: absolute;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  content: "";
}

.number-button.hot::after {
  top: 6px;
  background: var(--amber);
}

.number-button.late::before {
  bottom: 6px;
  background: var(--teal);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 128px;
  gap: 10px;
  margin-top: 16px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  font-weight: 850;
}

.primary-button {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.primary-button:hover {
  transform: translateY(-1px);
  background: var(--green-dark);
  box-shadow: 0 14px 24px rgba(15, 138, 95, 0.25);
}

.secondary-button {
  background: #ffffff;
}

.status-line {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-grid div {
  min-width: 0;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.summary-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-grid strong {
  display: block;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  line-height: 1.15;
}

.empty-state {
  display: grid;
  min-height: 210px;
  place-items: center;
  padding: 28px;
  border: 1px dashed #c9d7d1;
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--muted);
  text-align: center;
}

.empty-state .icon {
  width: 42px;
  height: 42px;
  color: var(--green);
}

.empty-state p {
  margin-bottom: 0;
  font-weight: 750;
}

.games-list {
  display: grid;
  gap: 10px;
}

.game-card {
  display: grid;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.game-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.game-title {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.score-badge {
  min-width: 72px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 900;
}

.balls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 6px;
}

.ball {
  display: grid;
  aspect-ratio: 1;
  min-width: 0;
  place-items: center;
  border-radius: 50%;
  background: #16241f;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 900;
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.game-meta span {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.notice {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #f0d79b;
  border-radius: 8px;
  background: var(--amber-soft);
  color: #6d4a0b;
}

.notice p {
  margin-bottom: 0;
  font-size: 0.84rem;
  font-weight: 700;
}

.stats-section {
  margin-top: 18px;
}

.stats-header {
  margin-bottom: 14px;
  padding-top: 6px;
}

.last-draw {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  max-width: 470px;
}

.last-draw strong {
  width: 100%;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.last-draw .mini-ball {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-dark);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 900;
}

.stats-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(320px, 0.78fr);
  gap: 18px;
}

.chart-panel,
.insight-panel {
  padding: 16px;
}

.frequency-chart {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: center;
}

.bar-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #16241f;
  color: #ffffff;
  font-weight: 900;
}

.bar-track {
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2ef;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
}

.bar-value {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: right;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.insight-panel.wide {
  grid-column: 1 / -1;
}

.rank-list,
.pair-list {
  display: grid;
  gap: 8px;
}

.rank-item,
.pair-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.rank-item strong,
.pair-item strong {
  color: var(--ink);
}

.pair-balls {
  display: flex;
  gap: 5px;
}

.pair-balls i {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #16241f;
  color: #ffffff;
  font-style: normal;
  font-size: 0.76rem;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 0 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

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

  .controls-panel {
    order: 1;
  }

  .results-panel {
    order: 2;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .stats-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-chip {
    width: 100%;
    justify-content: center;
    white-space: normal;
  }

  .control-grid,
  .summary-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .last-draw {
    justify-content: flex-start;
  }

  .last-draw strong {
    text-align: left;
  }

  .bar-row {
    grid-template-columns: 34px minmax(0, 1fr) 56px;
    gap: 8px;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 430px) {
  .brand-mark {
    width: 50px;
    height: 50px;
  }

  .number-board {
    gap: 6px;
  }

  .number-button {
    min-height: 44px;
  }

  .balls {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
