:root {
  --wine: #6f2432;
  --wine-dark: #4c1822;
  --gold: #c99720;
  --ink: #20242b;
  --muted: #66707c;
  --line: #dfe3e8;
  --surface: #ffffff;
  --page: #f3f5f7;
  --highlight: #fff5d7;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--page);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
a {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--wine);
  color: #fff;
  box-shadow: 0 2px 10px rgba(27, 17, 20, 0.22);
}

.topbar-inner {
  width: min(100%, 1040px);
  min-height: 76px;
  margin: 0 auto;
  padding: 10px 16px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.back-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  color: #fff;
  font-size: 25px;
  line-height: 1;
  text-decoration: none;
}

.title-wrap {
  min-width: 0;
}

.title-wrap h1 {
  margin: 0;
  color: #fff;
  font-size: 22px;
  line-height: 1.35;
}

.title-wrap p {
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.refresh-btn {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid #e8c665;
  border-radius: 6px;
  background: #f4d36e;
  color: #3f2b00;
  font-weight: 700;
  cursor: pointer;
}

.refresh-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.page-shell {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 18px 16px 32px;
}

.selection-section,
.stats-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.section-heading {
  min-height: 52px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
}

.status-text,
.selection-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.selected-grid {
  min-height: 102px;
  padding: 16px 14px;
  display: grid;
  grid-template-columns: repeat(8, minmax(56px, 1fr));
  gap: 12px 8px;
}

.number-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.number-ball {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(24, 28, 33, 0.28);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
}

.wave-red {
  background: #d63c43;
}

.wave-blue {
  background: #3769c7;
}

.wave-green {
  background: #32915c;
}

.number-label {
  margin-top: 4px;
  color: #4c5560;
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.table-scroll {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.stats-table th,
.stats-table td {
  height: 43px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.stats-table th {
  background: #303740;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.stats-table td {
  color: #343b44;
  font-size: 14px;
}

.stats-table tbody tr:last-child td {
  border-bottom: 0;
}

.stats-table tbody tr.highlight-row {
  background: var(--highlight);
}

.stats-table tbody tr.highlight-row td:first-child,
.stats-table tbody tr.highlight-row td:last-child {
  color: var(--wine-dark);
  font-weight: 800;
}

.wave-text-red {
  color: #c92f39;
}

.wave-text-blue {
  color: #285ebd;
}

.wave-text-green {
  color: #227a49;
}

@media (max-width: 700px) {
  .topbar-inner {
    min-height: 70px;
    padding: 9px 10px;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .back-btn {
    width: 36px;
    height: 36px;
  }

  .title-wrap h1 {
    font-size: 17px;
  }

  .title-wrap p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .refresh-btn {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .page-shell {
    padding: 12px 8px 24px;
  }

  .selected-grid {
    grid-template-columns: repeat(4, minmax(54px, 1fr));
    gap: 12px 4px;
  }

  .stats-table th,
  .stats-table td {
    padding: 8px 4px;
  }
}

@media (max-width: 380px) {
  .title-wrap h1 {
    font-size: 15px;
  }

  .refresh-btn {
    padding: 7px 8px;
  }
}
