:root {
  --bg: #0f1419;
  --bg-card: #ffffff;
  --bg-soft: #f4f6f9;
  --text: #1a2332;
  --text-muted: #6b7a90;
  --border: #e8ecf2;
  --primary: #c62828;
  --primary-dark: #8e0000;
  --accent: #1565c0;
  --accent-light: #e3f2fd;
  --red-ball: #e53935;
  --blue-ball: #1e88e5;
  --green-ball: #43a047;
  --gold: #ffb300;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(15, 20, 25, 0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ball-sm: 30px;
  --ball-draw: 34px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei UI", "Helvetica Neue", sans-serif;
  background: var(--bg-soft);
  color: var(--text);
  line-height: 1.4;
  min-height: 100vh;
  padding-bottom: var(--safe-bottom);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #1a1f36 0%, #2d1b3d 50%, #4a1528 100%);
  color: #fff;
  padding: calc(10px + var(--safe-top)) 10px 14px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 60%;
  height: 120%;
  background: radial-gradient(circle, rgba(198, 40, 40, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.hero-desc {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

/* Layout */
.wrap {
  flex: 1;
  max-width: 640px;
  margin: -10px auto 0;
  padding: 0 8px 10px;
  width: 100%;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

/* Toolbar */
.toolbar {
  padding: 8px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.input-wrap {
  flex: 1;
  min-width: 0;
}

.input-wrap input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  font: 14px Consolas, "SF Mono", monospace;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}

.input-wrap input:focus {
  border-color: var(--primary);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  min-width: 36px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s;
  touch-action: manipulation;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 14px;
  padding: 0;
  width: 36px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(198, 40, 40, 0.3);
}

.btn-block {
  width: 100%;
}

.btn-copy {
  min-height: 28px;
  min-width: auto;
  padding: 0 10px;
  font-size: 12px;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.btn-copy.copied {
  background: #e8f5e9;
  border-color: #43a047;
  color: #2e7d32;
}

.btn-copy-focus {
  color: #e65100;
  border-color: #ffcc80;
  background: #fff8e1;
}

.btn-copy-focus.copied {
  background: #e8f5e9;
  border-color: #43a047;
  color: #2e7d32;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
  justify-content: flex-end;
}

/* Draw card */
.draw-card {
  padding: 10px 8px;
}

.draw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.draw-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
}

.draw-expect {
  font-size: 1rem;
  font-family: Consolas, monospace;
  color: var(--primary);
}

.draw-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-red {
  background: #ffebee;
  color: #c62828;
}

.badge-blue {
  background: var(--accent-light);
  color: var(--accent);
}

.balls-row {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  padding: 2px 0 4px;
}

.ball-col {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
}

.ball-col .ball-label {
  display: block;
  margin-bottom: 3px;
  white-space: nowrap;
  line-height: 1;
}

.ball-col-special .ball-label {
  color: var(--primary);
  font-weight: 600;
}

.ball-zodiac {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  line-height: 1;
}

.ball-col-special .ball-zodiac {
  color: var(--primary);
}

.ball {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font: bold 11px Consolas, monospace;
  color: #fff;
  position: relative;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.balls-row .ball {
  width: var(--ball-draw);
  height: var(--ball-draw);
  max-width: var(--ball-draw);
  margin: 0 auto;
}

.ball.empty {
  background: #cfd8dc;
  border-color: #b0bec5;
  box-shadow: none;
  font-size: 10px;
}

.ball.wave-red {
  background: linear-gradient(145deg, #ef5350, var(--red-ball));
}

.ball.wave-blue {
  background: linear-gradient(145deg, #42a5f5, var(--blue-ball));
}

.ball.wave-green {
  background: linear-gradient(145deg, #66bb6a, var(--green-ball));
}

.ball.hit {
  box-shadow: 0 0 0 2px var(--gold) !important;
}

.ball.hit::after {
  content: "✓";
  position: absolute;
  top: -6px;
  right: -6px;
  width: 12px;
  height: 12px;
  background: #2e7d32;
  border: 1.5px solid #fff;
  border-radius: 50%;
  font-size: 8px;
  line-height: 9px;
  text-align: center;
  color: #fff;
  font-weight: bold;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  z-index: 3;
}

.balls-row .ball.hit::after {
  width: 14px;
  height: 14px;
  font-size: 9px;
  line-height: 11px;
}

.ball.focus {
  box-shadow: 0 0 0 2.5px #ff9800, 0 0 8px rgba(255, 152, 0, 0.45);
}

.ball.focus::before {
  content: "★";
  position: absolute;
  top: -5px;
  left: -5px;
  width: 14px;
  height: 14px;
  background: #ff9800;
  border: 1.5px solid #fff;
  border-radius: 50%;
  font-size: 8px;
  line-height: 12px;
  text-align: center;
  color: #fff;
  z-index: 1;
}

.ball.focus.hit {
  box-shadow: 0 0 0 2px var(--gold), 0 0 0 4.5px #ff9800, 0 2px 8px rgba(255, 152, 0, 0.4);
}

.hit-text {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 8px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  line-height: 1.4;
  word-break: break-all;
}

.hit-text.has-hit {
  color: #2e7d32;
  background: #e8f5e9;
}

/* Status */
.status-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin-bottom: 8px;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #90a4ae;
  flex-shrink: 0;
}

.status-bar.loading .status-dot {
  background: var(--primary);
  animation: pulse 1s ease infinite;
}

.status-bar.error .status-dot {
  background: #e53935;
}

.status-bar.ok .status-dot {
  background: #43a047;
}

.status-text {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

/* Hit log */
.hit-log-card {
  margin-bottom: 8px;
  padding: 10px 12px;
}

.hit-log-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.hit-log-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.hit-log-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.hit-log-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.hit-log-label {
  font-size: 11px;
  color: var(--text-muted);
}

.hit-log-input {
  width: 52px;
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
  background: #fff;
}

.hit-log-unit {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-hit-query {
  width: auto;
  min-width: auto;
  padding: 5px 12px;
  font-size: 12px;
  min-height: 0;
  white-space: nowrap;
}

.hit-log-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.hit-log-stat {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f5f7fa;
  color: var(--text-muted);
  white-space: nowrap;
}

.hit-log-stat b {
  color: var(--text);
  font-weight: 700;
}

.hit-log-stat.good b {
  color: #2e7d32;
}

.hit-log-stat.warn b {
  color: #e65100;
}

.hit-log-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.hit-log-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: #fafbfc;
  border: 1px solid #eef1f4;
  font-size: 11px;
}

.hit-log-draw {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex-wrap: wrap;
}

.hit-log-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.hit-log-balls .ball {
  width: 22px;
  height: 22px;
  font-size: 9px;
  line-height: 22px;
}

.hit-log-balls .ball.hit::after {
  width: 10px;
  height: 10px;
  font-size: 8px;
  line-height: 10px;
  top: -3px;
  right: -3px;
}

.hit-log-plus {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

.hit-log-special .ball {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.hit-log-row.is-hit {
  background: #e8f5e9;
  border-color: #c8e6c9;
}

.hit-log-period {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.hit-log-actual {
  color: var(--text-muted);
}

.hit-log-actual strong {
  color: var(--text);
  font-size: 12px;
}

.hit-log-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.hit-log-tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #eceff1;
  color: #78909c;
}

.hit-log-tag.ok {
  background: #c8e6c9;
  color: #2e7d32;
}

.hit-log-tag.no {
  background: #ffebee;
  color: #c62828;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Panels */
.panels {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel {
  overflow: hidden;
  padding: 8px;
}

.panel-right {
  border-top: 2px solid var(--primary);
}

.panel-left {
  border-top: 2px solid var(--accent);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.panel-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.panel h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.panel-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.zodiac-list {
  max-height: none;
}

.z-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 6px;
  margin-bottom: 4px;
  background: var(--bg-soft);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.z-row:last-child {
  margin-bottom: 0;
}

.z-name {
  flex-shrink: 0;
  width: 26px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding-top: 4px;
  line-height: 1.2;
}

.z-balls {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--ball-sm));
  gap: 5px;
  flex: 1;
  min-width: 0;
  align-content: start;
}

.z-balls .ball,
.z-balls .ball.hit {
  width: var(--ball-sm);
  height: var(--ball-sm);
  margin: 0;
  font-size: 11px;
}

.zodiac-list:empty::after {
  content: "暂无预测数据";
  display: block;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Loading mask */
.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.loading-mask[hidden] {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

body.loading {
  overflow: hidden;
}

#copyHelper {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: none;
  opacity: 0;
  pointer-events: none;
}

/* Tablet / Desktop */
@media (min-width: 720px) {
  html {
    font-size: 16px;
  }

  :root {
    --ball-sm: 40px;
    --ball-draw: 46px;
  }

  .hero {
    padding: calc(20px + var(--safe-top)) 16px 28px;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero-desc {
    font-size: 13px;
    margin-top: 6px;
  }

  .wrap {
    max-width: 960px;
    margin: -16px auto 0;
    padding: 0 20px 32px;
  }

  .card {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 14px;
  }

  .toolbar {
    padding: 14px;
  }

  .toolbar-row {
    gap: 8px;
    margin-bottom: 10px;
  }

  .input-wrap input {
    height: 44px;
    font-size: 16px;
    padding: 0 14px;
  }

  .btn {
    min-height: 44px;
    min-width: 44px;
    font-size: 15px;
  }

  .btn-ghost {
    width: 44px;
    font-size: 18px;
  }

  .btn-hit-query {
    width: auto;
    min-width: auto;
    font-size: 13px;
  }

  .draw-card {
    padding: 16px 14px;
  }

  .draw-head {
    margin-bottom: 14px;
  }

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

  .draw-expect {
    font-size: 1.25rem;
  }

  .badge {
    font-size: 12px;
    padding: 4px 10px;
  }

  .ball-col .ball-label {
    margin-bottom: 6px;
    font-size: 11px;
  }

  .ball-zodiac {
    margin-top: 8px;
    font-size: 12px;
  }

  .balls-row .ball {
    font-size: 14px;
  }

  .ball.hit::after {
    width: 14px;
    height: 14px;
    font-size: 9px;
    line-height: 11px;
  }

  .ball.focus::before {
    width: 16px;
    height: 16px;
    font-size: 9px;
    line-height: 14px;
    top: -6px;
    left: -6px;
  }

  .hit-text {
    font-size: 13px;
    padding: 10px 12px;
  }

  .status-bar {
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
  }

  .status-dot {
    width: 8px;
    height: 8px;
  }

  .panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .panel {
    padding: 16px;
  }

  .panel-right,
  .panel-left {
    border-top-width: 3px;
  }

  .panel-header {
    margin-bottom: 12px;
    padding-bottom: 12px;
    gap: 10px;
  }

  .panel-icon {
    font-size: 22px;
  }

  .panel h2 {
    font-size: 16px;
  }

  .panel-sub {
    font-size: 12px;
  }

  .btn-copy {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
  }

  .z-row {
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
  }

  .z-name {
    width: 32px;
    font-size: 16px;
    padding-top: 6px;
  }

  .z-balls {
    gap: 8px;
  }

  .z-balls .ball,
  .z-balls .ball.hit {
    font-size: 13px;
  }
}

@media (min-width: 720px) {
  :root {
    --ball-sm: 44px;
  }
}

/* 底部访问统计 */
.footer {
  text-align: center;
  padding: 24px 16px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
  background: linear-gradient(180deg, transparent 0%, rgba(198, 40, 40, 0.02) 100%);
}

.footer-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--bg-soft);
  border-radius: 20px;
  border: 1px solid var(--border);
}

.footer-icon {
  font-size: 16px;
  line-height: 1;
}

.footer-text {
  color: var(--text-muted);
  font-size: 13px;
}

.footer-count {
  color: var(--primary);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  min-width: 20px;
  text-align: center;
  transition: transform 0.2s ease;
}

.footer-count.pop {
  transform: scale(1.3);
}

.footer-unit {
  color: var(--text-muted);
  font-size: 13px;
}

/* Safari 强制提示弹窗 */
.safari-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.page.safari-blocked {
  pointer-events: none;
  filter: blur(4px);
  transition: filter 0.3s ease;
}


.copy-tip {
  margin-top: 16px;
  color: #636366;
  font-size: 12px;
  text-align: center;
}

.safari-overlay-inner {
  background: #1c1c1e;
  border-radius: 20px;
  padding: 32px 24px 24px;
  max-width: 340px;
  width: 88%;
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: safariSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes safariSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.safari-icon {
  font-size: 56px;
  margin-bottom: 16px;
  display: block;
  animation: safariPulse 2s ease-in-out infinite;
}

@keyframes safariPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.safari-overlay-inner h3 {
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.3;
}

.safari-overlay-inner p {
  color: #aeaeb2;
  font-size: 14px;
  line-height: 1.7;
  margin: 0 0 24px;
}

.safari-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 16px;
}

.safari-arrow {
  font-size: 22px;
  color: #0a84ff;
  animation: safariArrowBounce 1.2s ease-in-out infinite;
}

@keyframes safariArrowBounce {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(3px, -3px) rotate(-5deg); }
  50% { transform: translate(0, -5px) rotate(0deg); }
  75% { transform: translate(3px, -2px) rotate(5deg); }
}

.safari-hint span {
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
}



/* 网址复制区域 */
.url-copy-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.url-input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  outline: none;
  color: #0a84ff;
  font-size: 13px;
  padding: 12px 12px;
  text-align: center;
  letter-spacing: 0.3px;
}

.copy-btn {
  width: 100%;
  box-sizing: border-box;
  padding: 13px 0;
  border: none;
  border-radius: 10px;
  background: #0a84ff;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.copy-btn:active {
  transform: scale(0.97);
  background: #0071e3;
}

.copy-btn.copied {
  background: #30d158;
}

