:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --panel-2: #edf3f2;
  --text: #172026;
  --muted: #66737c;
  --line: #d9e1e4;
  --accent: #c03634;
  --accent-2: #12666a;
  --gold: #bd7f16;
  --ink: #21333a;
  --shadow: 0 10px 26px rgba(28, 42, 52, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% -10%, rgba(18, 102, 106, 0.12), transparent 260px),
    linear-gradient(180deg, #eef4f4 0, var(--bg) 240px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
}

h1 {
  margin: 0 0 4px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}

.stats div {
  min-height: 62px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.stats span {
  display: block;
  font-size: 22px;
  font-weight: 760;
  line-height: 1.15;
}

.stats small,
.latest small,
.metric small,
.position-item small {
  color: var(--muted);
}

.controls {
  display: grid;
  grid-template-columns: auto minmax(300px, 1fr);
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.segmented {
  display: grid;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.lottery-tabs {
  grid-template-columns: repeat(2, 82px);
}

.range-tabs {
  grid-template-columns: repeat(5, minmax(58px, 1fr));
}

.segmented button,
.pager button,
.ghost {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.segmented button {
  background: transparent;
}

.segmented button.active {
  background: var(--accent-2);
  color: #fff;
  font-weight: 700;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(23, 108, 112, 0.14);
}

.ghost {
  padding: 0 16px;
  background: #edf1f3;
}

.latest {
  display: grid;
  gap: 0;
  margin: 8px 0;
  padding: 7px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--ink), #193f42);
  color: #fff;
}

.latest-item {
  display: grid;
  grid-template-columns: minmax(116px, max-content) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 44px;
  min-width: 0;
}

.latest-item + .latest-item {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.prediction .ball {
  background: var(--accent-2);
}

.prediction .ball.gold {
  background: var(--gold);
}

.latest strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.15;
  white-space: nowrap;
}

.latest .balls {
  flex-wrap: nowrap;
  min-width: 0;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.view-tabs button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}

.view-tabs button.active {
  background: var(--accent-2);
  color: #fff;
}

.view-panel[hidden],
.pager[hidden] {
  display: none;
}

.analysis {
  margin: 8px 0 10px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 15px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

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

.metric {
  min-height: 86px;
  padding: 10px 12px;
}

.metric strong {
  display: block;
  margin: 4px 0 1px;
  font-size: 23px;
  line-height: 1.15;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

.metric span,
.panel-title span {
  color: var(--muted);
  font-size: 12px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.2fr;
  gap: 8px;
}

.panel {
  min-width: 0;
  padding: 11px;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.rank-list {
  display: grid;
  gap: 6px;
}

.rank-item {
  display: grid;
  grid-template-columns: 52px minmax(80px, 1fr) 104px;
  align-items: center;
  gap: 8px;
  min-height: 22px;
  font-variant-numeric: tabular-nums;
}

.rank-item span {
  font-weight: 700;
}

.rank-item strong {
  color: #43525b;
  font-size: 12px;
  text-align: right;
}

.bar {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8eef0;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), #3d9b8f);
}

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

.position-item {
  display: grid;
  gap: 2px;
  min-height: 64px;
  padding: 8px;
  border-radius: 8px;
  background: #f5f8f8;
}

.position-item span {
  color: #43525b;
  font-size: 12px;
}

.position-item strong {
  color: var(--accent);
  font-size: 23px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.balls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.ball {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.ball.clickable {
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.ball.clickable:hover,
.ball.clickable:focus {
  outline: none;
  transform: translateY(-1px);
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.16),
    0 0 0 3px rgba(18, 102, 106, 0.18);
}

.ball.highlight {
  background: #151c22;
  color: #fff;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.22),
    0 0 0 3px rgba(192, 54, 52, 0.22);
}

.ball.gold {
  background: var(--gold);
}

.ball.gold.highlight {
  background: #151c22;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mobile-list {
  display: none;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f7f8;
  color: #43525b;
  font-size: 13px;
}

tbody tr:hover {
  background: #f8fbfb;
}

td:first-child {
  font-weight: 750;
}

.numbers {
  display: flex;
  gap: 5px;
}

.numbers .ball {
  width: 25px;
  height: 25px;
  font-size: 12px;
}

a {
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.empty {
  padding: 48px 16px;
  color: var(--muted);
  text-align: center;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.pager button {
  min-width: 86px;
  min-height: 36px;
  background: var(--accent-2);
  color: #fff;
}

.pager button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

#pageText {
  min-width: 120px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .metric-grid,
  .analysis-grid {
    grid-template-columns: 1fr 1fr;
  }

  .analysis-grid .panel:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  body {
    background: var(--bg);
  }

  .shell {
    width: 100%;
    padding: 10px 8px 24px;
  }

  h1 {
    font-size: 22px;
  }

  p,
  .metric span,
  .panel-title span {
    font-size: 12px;
  }

  .topbar {
    gap: 8px;
    margin-bottom: 8px;
  }

  .stats {
    gap: 6px;
  }

  .stats div {
    min-height: 54px;
    padding: 8px 10px;
  }

  .stats span {
    font-size: 19px;
  }

  .stats,
  .controls,
  .metric-grid,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    gap: 7px;
    padding: 8px;
  }

  .segmented {
    width: 100%;
  }

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

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

  .segmented button,
  .ghost {
    min-height: 38px;
  }

  .latest {
    margin: 7px 0;
    padding: 9px;
  }

  .latest-item {
    grid-template-columns: 1fr;
    gap: 6px;
    min-height: auto;
  }

  .latest-item + .latest-item {
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    padding-top: 10px;
  }

  .latest strong {
    font-size: 15px;
  }

  .view-tabs {
    margin: 7px 0;
  }

  .balls,
  .latest .balls {
    justify-content: flex-start;
  }

  .ball {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  h2 {
    font-size: 18px;
  }

  h3 {
    font-size: 15px;
  }

  .metric {
    min-height: auto;
    padding: 10px;
  }

  .metric strong {
    font-size: 22px;
  }

  .panel {
    padding: 10px;
  }

  .panel-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
  }

  .analysis-grid .panel:last-child {
    grid-column: auto;
  }

  .rank-item {
    grid-template-columns: 48px minmax(90px, 1fr) 100px;
    gap: 7px;
  }

  .rank-item strong {
    grid-column: auto;
    text-align: right;
    font-size: 12px;
  }

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

  .position-item {
    min-height: 62px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  table {
    display: none;
  }

  .mobile-list {
    display: grid;
    gap: 8px;
  }

  .draw-card {
    display: grid;
    gap: 9px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 10px 28px rgba(28, 42, 52, 0.07);
  }

  .draw-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .draw-card-head strong {
    font-size: 15px;
  }

  .draw-card-head span {
    color: var(--muted);
    font-size: 13px;
  }

  .card-numbers {
    flex-wrap: wrap;
  }

  .card-numbers .ball {
    width: 29px;
    height: 29px;
  }

  .draw-card a {
    justify-self: start;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 6px;
    background: #e8f1f1;
  }

  .empty {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
  }

  .pager {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 10px -8px -24px;
    padding: 8px;
    border-top: 1px solid var(--line);
    background: rgba(246, 247, 249, 0.94);
    backdrop-filter: blur(10px);
  }

  .pager button {
    min-width: 78px;
  }

  #pageText {
    min-width: 92px;
    font-size: 13px;
  }
}
