:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #657085;
  --line: #dfe6ef;
  --primary: #345d91;
  --primary-soft: #eaf1fa;
  --danger: #d92d3a;
  --danger-soft: #fff0f1;
  --warning: #9a630a;
  --warning-soft: #fff6df;
  --success: #167a4d;
  --success-soft: #e9f8f0;
  --red: #ed1b2b;
  --blue: #2054d7;
  --green: #149a59;
  --shadow: 0 16px 42px rgba(32, 51, 83, .08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

html,
body,
button {
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 6% 0, rgba(55, 94, 145, .08), transparent 28rem),
    radial-gradient(circle at 94% 2%, rgba(199, 70, 59, .06), transparent 25rem),
    var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(52, 93, 145, .26);
  outline-offset: 3px;
}

.page {
  width: min(960px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding: 12px 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.record-switch {
  display: flex;
  flex-wrap: wrap;
  padding: 3px;
  border: 1px solid #d8e1ec;
  border-radius: 11px;
  background: rgba(255, 255, 255, .78);
}

.record-link {
  padding: 7px 10px;
  border-radius: 8px;
  color: #65758a;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.record-link.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(52, 93, 145, .18);
}

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

.brand-mark {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(145deg, #3e689b, #294f7d);
  box-shadow: 0 8px 20px rgba(39, 78, 125, .22);
  color: #fff;
  font: 500 28px/1 STXingkai, "华文行楷", KaiTi, serif;
}

.eyebrow,
.section-label {
  margin: 0 0 3px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 2px;
  font-size: clamp(25px, 4vw, 32px);
  line-height: 1.1;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.back {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid #d2dce9;
  border-radius: 10px;
  background: rgba(255, 255, 255, .82);
  color: #355d8d;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.back:hover {
  border-color: #aebfd3;
  background: #fff;
  transform: translateY(-1px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.current-panel {
  position: relative;
  overflow: hidden;
  padding: 22px;
}

.current-panel::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--red) 0 33.3%, var(--blue) 33.3% 66.6%, var(--green) 66.6%);
  content: "";
}

.panel-heading,
.history-heading,
.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.issue-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.issue-line strong {
  color: var(--text);
  font: 900 22px/1.15 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .02em;
}

.draw-date {
  font-size: 12px;
}

.snowball-badge,
.history-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid #e8c66e;
  border-radius: 999px;
  background: #fff8df;
  color: #8b6200;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.snowball-badge {
  margin-top: 7px;
  padding: 5px 8px;
}

.snowball-badge[hidden] {
  display: none;
}

.history-tag {
  padding: 4px 6px;
}

.status {
  flex: 0 0 auto;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.status.running {
  background: var(--warning-soft);
  color: var(--warning);
}

.status.complete {
  background: var(--success-soft);
  color: var(--success);
}

.status.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.delay-alert {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 16px 0 0;
  padding: 11px 13px;
  border: 1px solid #f3c8cc;
  border-radius: 12px;
  background: var(--danger-soft);
  color: #9e2630;
}

.delay-alert[hidden] {
  display: none;
}

.delay-icon {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-weight: 900;
}

.delay-alert strong {
  font-size: 13px;
}

.delay-alert p {
  margin: 2px 0 0;
  font-size: 12px;
}

.balls {
  display: grid;
  grid-template-columns: repeat(6, minmax(64px, 1fr)) 30px minmax(64px, 1fr);
  align-items: start;
  gap: clamp(7px, 1.4vw, 13px);
  margin-top: 24px;
}

.ball-item {
  min-width: 0;
  text-align: center;
}

.ball {
  position: relative;
  display: grid;
  width: 100%;
  max-width: 96px;
  aspect-ratio: 1;
  margin: 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid #e0e6ee;
  border-radius: 50%;
  background: linear-gradient(145deg, #f5f7fa, #e6ebf1);
  box-shadow:
    inset 0 -7px 12px rgba(40, 53, 74, .11),
    inset 0 5px 8px rgba(255, 255, 255, .55),
    0 7px 14px rgba(29, 42, 63, .12);
  color: #8b95a5;
  font: 900 clamp(24px, 4.4vw, 40px)/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.ball::after {
  position: absolute;
  top: 11%;
  left: 20%;
  width: 33%;
  height: 18%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
  content: "";
  filter: blur(1px);
  transform: rotate(-18deg);
}

.ball.red {
  border-color: #d91728;
  background: linear-gradient(145deg, #fa3543, #d90f20);
  color: #fff;
}

.ball.blue {
  border-color: #1948bd;
  background: linear-gradient(145deg, #3267e5, #1647c3);
  color: #fff;
}

.ball.green {
  border-color: #0f8149;
  background: linear-gradient(145deg, #22ab69, #0d884d);
  color: #fff;
}

.zodiac {
  min-height: 24px;
  padding-top: 7px;
  color: #263247;
  font-size: 15px;
  font-weight: 900;
}

.plus {
  display: grid;
  height: clamp(64px, 8vw, 96px);
  place-items: center;
  color: var(--danger);
  font-size: 26px;
  font-weight: 900;
}

.capture-progress {
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--surface-soft);
}

.progress-copy {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4eaf1;
}

.progress-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #5e85b5);
  transition: width .35s ease;
}

.draw-note {
  margin: 18px 0 0;
  padding: 11px 13px;
  border-radius: 11px;
  background: #f5f8fc;
  color: #5c687c;
  font-size: 12px;
  line-height: 1.65;
}

.source-note {
  margin: 10px 2px 0;
  color: #7c8798;
  font-size: 11px;
  line-height: 1.6;
}

.source-note a {
  color: var(--primary);
  font-weight: 800;
  text-underline-offset: 2px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.metric {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #e6ebf2;
  border-radius: 11px;
  background: var(--surface-soft);
}

.metric-label {
  display: block;
  margin-bottom: 4px;
  color: #7b8799;
  font-size: 10px;
}

.metric strong {
  display: block;
  overflow: hidden;
  color: #344158;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric strong.good {
  color: var(--success);
}

.metric strong.bad {
  color: var(--danger);
}

.updated {
  min-height: 16px;
  margin: 9px 2px 0;
  color: #8994a5;
  text-align: right;
  font-size: 10px;
}

.history-panel {
  margin-top: 12px;
  padding: 18px;
}

.history-heading {
  align-items: end;
  margin-bottom: 10px;
}

.history-heading h2 {
  margin: 0;
  font-size: 18px;
}

.history-heading > span {
  color: #8994a5;
  font-size: 11px;
}

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

.history-empty {
  padding: 24px 8px;
  color: #8d98a9;
  text-align: center;
  font-size: 13px;
}

.history-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #e6ebf2;
  border-radius: 11px;
  background: #fafbfd;
  transition: border-color .2s ease, background .2s ease;
}

.history-row:first-child {
  border-color: #cfdbea;
  background: #f6f9fd;
}

.history-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.history-issue {
  color: #344158;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.history-date {
  color: #8994a5;
  font-size: 10px;
  white-space: nowrap;
}

.history-numbers {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 5px;
  min-width: 0;
}

.history-number-wrap {
  display: grid;
  width: 40px;
  justify-items: center;
}

.history-number {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, .12);
  color: #fff;
  font: 900 16px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.history-number.red {
  background: var(--red);
}

.history-number.blue {
  background: var(--blue);
}

.history-number.green {
  background: var(--green);
}

.history-number.special {
  outline: 2px solid #efb8bd;
  outline-offset: 2px;
}

.history-zodiac {
  margin-top: 4px;
  color: #344158;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.history-plus {
  display: grid;
  width: 12px;
  height: 40px;
  place-items: center;
  color: var(--danger);
  font-size: 17px;
  font-weight: 900;
}

footer {
  margin-top: 20px;
  color: #8a95a6;
  text-align: center;
  font-size: 10px;
  line-height: 1.8;
}

.online-lock {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(244, 247, 251, .98);
}

.online-message {
  padding: 22px 28px;
  border: 1px solid #dbe3ee;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  color: #506078;
  text-align: center;
}

.online-message b {
  display: block;
  margin-bottom: 6px;
  color: #294d78;
  font-size: 17px;
}

.online-retry {
  display: none;
  margin: 13px auto 0;
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 800;
}

.online-lock.failed .online-retry {
  display: block;
}

@media (max-width: 720px) {
  .page {
    width: min(100% - 14px, 620px);
    padding-top: 7px;
  }

  .site-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    padding: 7px 4px;
  }

  .header-actions {
    justify-content: space-between;
    width: 100%;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 24px;
  }

  h1 {
    font-size: 24px;
  }

  .subtitle {
    display: none;
  }

  .back {
    padding: 8px 10px;
    font-size: 12px;
  }

  .record-link {
    padding: 7px 9px;
  }

  .current-panel {
    padding: 17px 11px 13px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .issue-line strong {
    font-size: 19px;
  }

  .balls {
    grid-template-columns: repeat(6, minmax(0, 1fr)) 14px minmax(0, 1fr);
    gap: 4px;
    margin-top: 19px;
  }

  .ball {
    max-width: 68px;
    border-width: 0;
    font-size: clamp(19px, 7vw, 29px);
    box-shadow:
      inset 0 -4px 7px rgba(40, 53, 74, .13),
      0 4px 8px rgba(29, 42, 63, .1);
  }

  .zodiac {
    min-height: 20px;
    padding-top: 5px;
    font-size: 12px;
  }

  .plus {
    height: auto;
    aspect-ratio: .45;
    font-size: 19px;
  }

  .draw-note {
    margin-top: 13px;
  }

  .metrics {
    gap: 5px;
  }

  .metric {
    padding: 9px 7px;
  }

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

  .history-panel {
    padding: 13px 8px 9px;
  }

  .history-row {
    display: block;
    padding: 9px 7px;
  }

  .history-meta {
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 7px;
  }

  .history-numbers {
    justify-content: flex-start;
    gap: 3px;
  }

  .history-number-wrap {
    width: clamp(33px, 10vw, 42px);
  }

  .history-number {
    font-size: clamp(14px, 4.6vw, 17px);
  }

  .history-zodiac {
    font-size: 11px;
  }

  .history-plus {
    width: 8px;
    height: clamp(33px, 10vw, 42px);
    font-size: 15px;
  }
}

@media (max-width: 390px) {
  .page {
    width: calc(100% - 8px);
  }

  .current-panel {
    padding-right: 7px;
    padding-left: 7px;
  }

  .header-actions {
    align-items: flex-start;
    gap: 5px;
  }

  .record-switch {
    flex: 1 1 auto;
    gap: 1px;
  }

  .record-link {
    padding: 6px 7px;
    font-size: 11px;
  }

  .back {
    padding: 7px 8px;
    white-space: nowrap;
  }

  .status {
    padding: 6px 8px;
  }

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

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
