/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --purple: #6959CD;
  --red: #FF0000;
  --blue: #0000FF;
  --ball-red-bg: #D90808;
  --ball-blue-bg: #0A3DDF;
  --ball-green-bg: #159A3B;
}
html { scroll-behavior: smooth; }
body {
  font-family: "PingFang SC","Microsoft YaHei",system-ui,-apple-system,sans-serif;
  background: #000; /* 深色打底，突出紫色与球块 */
  color: #333;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ===== 顶部开奖区 ===== */
.lottery-section {
  background: linear-gradient(135deg, #6959CD 0%, #5140b0 100%);
  padding: 14px 12px 12px;
  color: #fff;
}
.lottery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}
.lottery-title { letter-spacing: 1px; }
.lottery-period b { color: #FFE066; margin: 0 2px; }
.lottery-balls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 60px;
}
.ball-loading { color: #fff; font-size: 13px; }

/* 号码方块（图2风格） */
.ball {
  text-align: center;
  background: #fff;
  border-radius: 8px;
  padding: 4px 2px 2px;
  min-width: 42px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.ball-num {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
  border-radius: 6px;
  background: #888; /* 默认，JS 按波色替换 */
}
.ball-zodiac {
  display: block;
  font-size: 11px;
  color: #333;
  margin-top: 2px;
}
.ball.special { border: 2px solid #FFE066; }
.ball-plus {
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  padding: 0 2px;
}
.ball.b-red .ball-num { background: var(--ball-red-bg); }
.ball.b-blue .ball-num { background: var(--ball-blue-bg); }
.ball.b-green .ball-num { background: var(--ball-green-bg); }
.ball.b-blue { border-color:#0A3DDF; }

.lottery-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.lottery-date { font-size: 12px; opacity: .9; }
.history-btn {
  background: #2D6CF0;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
.history-btn:active { transform: scale(.96); }

/* ===== 群码区 ===== */
.qr-section {
  background: none;
  padding: 18px 12px 10px;
}
.qr-box {
  background: #fff;
  border-radius: 14px;
  text-align: center;
  padding: 16px 14px 18px;
  position: relative;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.qr-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 18px;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(255,0,0,.5);
}
.qr-img-wrap {
  position: relative;
  max-width: 220px;
  margin: 12px auto 10px;
  border: 2px dashed #c9c9c9;
  border-radius: 10px;
  overflow: hidden;
}
.qr-img-wrap img {
  display: block;
  width: 100%;
  height: auto;
}
.qr-mask {
  position: absolute;
  inset: 0;
  background: rgba(255,0,0,.9);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  padding: 10px;
}
.qr-mask.show { display: flex; }
.qr-guide {
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.qr-refresh {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg,#ff4d4d,#e60000);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 2px;
  box-shadow: 0 3px 8px rgba(230,0,0,.4);
}
.qr-refresh:active { transform: scale(.97); }

/* ===== 浮动财神（内联 SVG，pointer-events 控制拖拽与穿透） ===== */
.caishen-float {
  position: fixed;
  z-index: 5; /* 低于弹窗(999)与提示(9999)，高于普通内容 */
  width: 72px;
  height: 96px;
  cursor: grab;
  pointer-events: none;   /* 容器本身穿透点击，不遮挡底层按钮 */
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.4));
}
.caishen-inner {
  width: 100%;
  height: 100%;
  pointer-events: auto;   /* 仅财神图形区域可点击/拖拽 */
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.caishen-inner svg { display: block; width: 100%; height: 100%; }
.caishen-float:active .caishen-inner { cursor: grabbing; }

/* ===== 表格区 ===== */
.table-section {
  background: #fff;
  margin: 0 0 30px;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}
.table-title {
  background: var(--purple);
  color: #fff;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  padding: 12px;
  letter-spacing: 2px;
  border-bottom: 1px solid #fff;
}
.table-list { border-top: 2px solid var(--purple); }
.table-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 8px;
  border-bottom: 1px solid #eee;
  font-size: 17px;
  flex-wrap: wrap;
}
.table-row:nth-child(even) { background: #fafaff; }
.row-period { font-weight: 800; }
.row-period b { color: var(--purple); }
.row-kill {
  background: var(--red);
  color: #fff; /* 红底白字"砍" */
  font-weight: 800;
  font-size: 14px;
  padding: 2px 7px;
  border-radius: 6px;
}
.row-content { font-weight: 700; }
.row-content .book { color: #333; }
.row-result { color: var(--blue); font-weight: 700; }
.row-result.row-miss { color: var(--red); }

/* 遮蔽蒙层 */
.row-masked .row-content {
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  padding: 4px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(255,0,0,.5);
  cursor: pointer;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
.row-masked { background: #fff0f0 !important; }

.table-empty { text-align: center; color: #888; padding: 30px; }

/* ===== 大红字提示 ===== */
.refresh-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%) scale(.8);
  background: var(--red);
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  padding: 22px 30px;
  border-radius: 12px;
  z-index: 9999;
  text-align: center;
  box-shadow: 0 6px 20px rgba(255,0,0,.6);
  opacity: 0;
  pointer-events: none;
  transition: all .35s;
}
.refresh-toast.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }

.row-result.row-pending { color: #999; }

/* ===== 历史开奖记录弹窗 ===== */
.history-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.history-modal.show { display: flex; }
.history-panel {
  background: #fff;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--purple);
  color: #fff;
  padding: 12px 16px;
}
.history-head h3 { font-size: 17px; letter-spacing: 1px; }
.history-head-right { display: flex; align-items: center; gap: 10px; }
.history-head-right select {
  border: none;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  background: #fff;
  color: #333;
}
.history-close {
  background: transparent;
  border: 1px solid rgba(255,255,255,.6);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.history-body {
  overflow-y: auto;
  padding: 8px 4px 16px;
  min-height: 120px;
}
.history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #f0f0f0;
  flex-wrap: wrap;
  font-size: 12px;
}
.history-row:nth-child(odd) { background: #fafaff; }
.h-period { width: 62px; font-weight: 700; color: #222; }
.h-nums { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; flex: 1; }
.h-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  font-size: 11px;
}
.h-ball.h-red { background: var(--ball-red-bg); }
.h-ball.h-blue { background: var(--ball-blue-bg); }
.h-ball.h-green { background: var(--ball-green-bg); }
.h-ball.h-sp { box-shadow: 0 0 0 2px #FFE066; }
.h-plus { color: var(--red); font-size: 14px; margin: 0 1px; }
.h-date { color: #999; font-size: 11px; }
.history-loading, .history-empty { text-align: center; color: #888; padding: 40px 0; font-size: 14px; }