* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #e9ebee;
  color: #333;
  font-size: 14px;
  line-height: 1.5;
}
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
.app {
  position: relative;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: #f7f8fa;
  padding-bottom: 62px;
  overflow: hidden;
}
.page { display: none; min-height: calc(100vh - 62px); }
.page.active { display: block; }

.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #fff;
  border-bottom: 1px solid #e9eaec;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 700; color: #222; }
.calendar-btn {
  position: absolute;
  right: 14px;
  top: 9px;
  padding: 4px 10px;
  font-size: 13px;
  color: #e33;
  background: #fff;
  border: 1px solid #e33;
  border-radius: 3px;
}
.loading, .empty { padding: 32px 12px; text-align: center; color: #999; font-size: 13px; }
.foot-note { text-align: center; color: #aaa; font-size: 11px; padding: 18px 10px 6px; margin: 0; }

/* 底部导航 */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  z-index: 50;
  width: 100%;
  max-width: 480px;
  height: 56px;
  display: flex;
  background: #fff;
  border-top: 1px solid #e6e7e9;
  box-shadow: 0 -2px 10px rgba(0,0,0,.04);
}
.tabbar button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #8a8f99;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  padding: 5px 0 3px;
}
.tabbar button svg { width: 22px; height: 22px; fill: currentColor; }
.tabbar button.active { color: #2f7de1; }

/* 首页 */
.home-list { padding: 12px 10px 4px; }
.home-card {
  margin-bottom: 12px;
  padding: 10px 12px 12px;
  background: #fff;
  text-align: left;
}
.home-card .card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 9px; }
.home-card .site-name { font-size: 15px; font-weight: 700; color: #333; }
.home-card .home-issue { font-size: 12px; color: #999; }
.home-card .card-body { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.home-card .countdown { color: #4a6fa5; font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.home-card .countdown small { font-weight: 400; font-size: 13px; }
.home-card .history-link {
  margin-left: auto;
  flex: 0 0 auto;
  color: #2f7de1;
  font-size: 13px;
  text-decoration: underline;
  border: 0;
  background: none;
  padding: 0;
}
.home-card .home-balls { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; }
.home-card .site-error { color: #e33; font-size: 12px; }

/* 历史开奖 */
.year-tabs { display: flex; gap: 6px; padding: 12px 10px 0; }
.year-tabs button {
  flex: 0 0 auto;
  min-width: 62px;
  padding: 7px 12px;
  text-align: center;
  background: #f0f1f3;
  border: 1px solid #e6e7e9;
  border-radius: 2px;
  color: #666;
  font-size: 13px;
}
.order-tabs { display: flex; gap: 8px; padding: 10px 10px 0; }
.order-tabs button {
  min-width: 84px;
  padding: 6px 12px;
  background: #f0f1f3;
  border: 1px solid #e6e7e9;
  border-radius: 2px;
  color: #666;
  font-size: 13px;
}
.year-tabs button.active, .order-tabs button.active {
  background: #fff;
  border-color: #f08a24;
  color: #e6740c;
  font-weight: 600;
}
.history-list { padding: 4px 10px 16px; }
.history-item { padding: 12px 0 10px; border-bottom: 1px solid #ececec; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.history-title { font-size: 14px; font-weight: 700; color: #333; }
.history-title b { color: #2f7de1; font-weight: 700; }
.history-date { flex: 0 0 auto; font-size: 13px; color: #666; }
.history-balls { display: flex; align-items: flex-start; gap: 3px; }
.history-balls .ball-item { flex: 1; min-width: 0; }
.history-balls .ball { width: 100%; max-width: 42px; height: 42px; }
.history-balls .ball-item .zodiac { font-size: 13px; }
.history-balls .ball-plus { align-self: center; font-size: 15px; }

/* 中式金边相框 */
.gold-frame, .draw-strip {
  position: relative;
  background: #fff;
  border: 2px solid #dcae52;
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 5px #f5dfa9;
  margin: 10px;
}
.gold-frame::before, .gold-frame::after,
.draw-strip::before, .draw-strip::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #dcae52;
  pointer-events: none;
}
.gold-frame::before, .draw-strip::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.gold-frame::after, .draw-strip::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }

/* 站点/筛选按钮 */
.site-pills, .pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 10px 0;
}
.pill-row { padding: 7px 10px 0; }
.pill {
  min-width: 62px;
  padding: 5px 10px;
  text-align: center;
  background: #f0f1f3;
  border: 1px solid transparent;
  border-radius: 2px;
  color: #444;
  font-size: 13px;
  line-height: 1.4;
}
.pill.active {
  background: #fff;
  border-color: #f08a24;
  color: #e6740c;
  font-weight: 600;
}
.filter-bar { padding-bottom: 2px; }

/* 开奖球 */
.draw-strip { padding: 14px 8px 8px; min-height: 78px; }
.ball-group { display: flex; align-items: flex-start; justify-content: center; gap: 5px; flex-wrap: wrap; }
.ball-item { display: flex; flex-direction: column; align-items: center; min-width: 38px; }
.ball {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid rgba(0,0,0,.18);
  box-shadow: inset 0 2px 3px rgba(255,255,255,.6), inset 0 -3px 5px rgba(0,0,0,.2), 0 1px 2px rgba(0,0,0,.2);
  text-shadow: 0 1px 1px rgba(0,0,0,.35);
}
.ball.red { background: radial-gradient(circle at 35% 28%, #ff8b7f, #d62828 70%, #8f1010); }
.ball.blue { background: radial-gradient(circle at 35% 28%, #8fc4ff, #2b6fd6 70%, #17408c); }
.ball.green { background: radial-gradient(circle at 35% 28%, #8bdba0, #219653 70%, #0f6b34); }
.ball.ball-img {
  border: 0;
  box-shadow: none;
  color: transparent;
  text-shadow: none;
}
.ball-item .zodiac { font-size: 14px; color: #444; margin-top: 3px; }
.ball-plus { align-self: center; font-size: 17px; font-weight: 700; color: #b27722; margin: 0 2px; }
.strip-meta { text-align: center; font-size: 14px; color: #999; margin-top: 6px; }
.strip-empty { text-align: center; color: #999; font-size: 12px; padding: 18px 0; }

/* 走势表格 */
.table-wrap { overflow: auto; padding: 0 10px 16px; height: 440px; }
.trend-table { border-collapse: collapse; width: 100%; min-width: 360px; font-size: 11px; table-layout: fixed; }
.trend-table th, .trend-table td {
  border: 1px solid #b8d69a;
  padding: 4px 2px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  height: 27px;
}
.trend-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef6e4;
  color: #35542b;
  font-weight: 600;
  box-shadow: inset 0 -1px 0 #b8d69a, inset 0 1px 0 #b8d69a;
}
.trend-table thead tr:nth-child(2) th { top: 27px; }
.trend-table tbody tr:nth-child(even) td { background: #fafdf6; }
.trend-table td.issue { background: #f2f6ef; color: #555; font-weight: 600; }
.trend-table td.hit { background: #ff5b5b !important; color: #fff; font-weight: 700; }
.trend-table td.special { background: #fff3e0; }
.trend-table td.special.hit { background: #ff5b5b !important; }
.trend-table td.tail { font-size: 10px; }
.trend-table td.tail-cell { background: #fff; }
.trend-table td.tail-cell.has { background: #dcefd0; font-weight: 600; }
.trend-table td.tail-cell.has.hit { background: #ff5b5b !important; color: #fff; }
.trend-table td.tail-count { background: #f2f6ef; font-weight: 600; }

/* 尾数统计 */
.tail-stats { display: none; gap: 10px; padding: 0 10px 18px; }
.tail-stats.show { display: flex; }
.tail-stat-card { flex: 1; background: #fff; border: 1px solid #e2e2e2; }
.tail-stat-card h3 {
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid #eee;
}
.tail-stat-card ul { margin: 0; padding: 8px 12px 12px; list-style: none; }
.tail-stat-card li { font-size: 13px; line-height: 2; color: #333; }
.tail-stat-card li b { color: #e33; font-weight: 700; }

/* 看料 */
.tuku-list { padding: 0 10px 16px; }
.tuku-list img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 10px;
  background: #f5f6fa;
  cursor: pointer;
}

/* 挑码助手 */
.seg-tabs {
  display: flex;
  margin: 12px 10px 10px;
  background: #eceef0;
  padding: 3px;
  border-radius: 4px;
}
.seg-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 0;
  color: #666;
  border-radius: 3px;
}
.seg-tabs button.active { background: #fff; color: #222; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg-tabs.inner { margin: 0 0 12px; }
.tool-panel { display: none; }
.tool-panel.active { display: block; }
.pick-box {
  margin: 12px 10px 0;
  border: 1px solid #dedfe1;
  background: #fff;
}
.picked-balls {
  min-height: 180px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  padding: 8px;
}
.pick-box .ball { width: 28px; height: 28px; font-size: 12px; }
.hint { color: #aaa; font-size: 12px; padding: 8px; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.pick-actions { margin: 10px; }
.btn {
  flex: 1;
  border-radius: 3px;
  padding: 9px 8px;
  font-size: 14px;
  border: 1px solid transparent;
}
.btn-outline { background: #fff; border-color: #33a86a; color: #1e9b5c; }
.btn-orange { background: #ff5a1f; color: #fff; font-weight: 600; border-color: #ff5a1f; width: 100%;}
.btn-teal { background: #179c86; color: #fff; font-weight: 600; border-color: #179c86; }
.btn-blue { background: #2f7de1; color: #fff; font-weight: 600; border-color: #2f7de1; }
.filter-groups { padding: 0 10px 18px; }
.filter-group { margin-bottom: 8px; }
.filter-buttons { display: grid; gap: 5px; }
.filter-btn {
  min-width: 0;
  width: 100%;
  padding: 9px 2px;
  background: #f5f6f8;
  border: 1px solid #e6e7e9;
  border-radius: 2px;
  font-size: 13px;
  color: #444;
}
.filter-btn.active { background: #e8f1ff; border-color: #2f7de1; color: #2f7de1; font-weight: 600; }

/* 复式计算 */
.calc-section {
  margin: 0 10px 12px;
  padding: 14px 12px 16px;
  background: #fff;
  border: 1px solid #ececec;
}
.calc-title { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: #222; }
.field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}
.field > span { flex: 0 0 80px; color: #555; }
.field input, .field select {
  flex: 1;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #dcdfe3;
  background: #fff;
  border-radius: 2px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: #2f7de1; }
.field em { font-style: normal; color: #aaa; font-size: 12px; flex: 0 0 auto; }
.calc-result { text-align: center; margin: 14px 0 2px; font-size: 13px; color: #555; }
.calc-result b { color: #ff5a1f; font-size: 17px; }
.calc-source { display: none; }
.calc-source.active { display: block; }
.num-grid, .zodiac-grid { display: grid; gap: 8px; margin-bottom: 12px; }
.num-grid { grid-template-columns: repeat(7, 1fr); }
.zodiac-grid { grid-template-columns: repeat(4, 1fr); }
.num-cell, .zodiac-cell {
  position: relative;
  border: 0;
  background: transparent;
  padding: 2px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.num-cell .ball { width: 30px; height: 30px; font-size: 13px; }
.num-cell.selected .ball, .zodiac-cell.selected .ball { outline: 2px solid #2f7de1; outline-offset: 2px; }
.zodiac-cell .ball { width: 36px; height: 36px; font-size: 14px; }
.zodiac-cell .zodiac-name { font-size: 11px; margin-top: 3px; color: #555; }
.calc-stat { background: #f9fafb; border: 1px solid #e8e9eb; padding: 9px 10px; font-size: 13px; color: #555; margin-bottom: 10px; }
.calc-stat b { color: #ff5a1f; }
.combo-result { margin-top: 12px; font-size: 13px; color: #555; }
.combo-result .combo-head {
  padding: 16px 8px;
  text-align: center;
  background: #fff;
  border-bottom: 1px solid #eee;
}
.combo-result .combo-head b { color: #ff5a1f; font-size: 15px; }
.combo-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 12px 0;
}
.combo-item {
  background: #2196f3;
  color: #fff;
  text-align: center;
  padding: 9px 2px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combo-copy { margin-top: 8px; }

/* 弹窗 / 预览 / 提示 */
.modal { display: none; position: fixed; inset: 0; z-index: 100; }
.modal.show { display: block; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-box {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 84%;
  max-width: 340px;
  background: #fff;
  border-radius: 6px;
  padding: 18px;
}
.modal-box h3 { margin: 0 0 14px; font-size: 15px; text-align: center; }
.modal-box input { width: 100%; padding: 9px; border: 1px solid #dcdfe3; border-radius: 3px; margin-bottom: 6px; }
.lightbox { display: none; position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.92); text-align: center; }
.lightbox.show { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lightbox img { max-width: 94%; max-height: 82vh; object-fit: contain; }
.lightbox-close { color: #fff; font-size: 13px; margin-top: 14px; }
.toast {
  position: fixed;
  left: 50%; bottom: 86px;
  transform: translateX(-50%) translateY(10px);
  background: rgba(0,0,0,.78);
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
