/* 前台：澳门六合彩展示 */

:root {
  --pub-bg: #f6f0e8;
  --pub-card: #fffef8;
  --pub-text: #2c2416;
  --pub-muted: #7a6f63;
  --pub-accent: #c41e1e;
  --ball-red: linear-gradient(145deg, #ff6b6b 0%, #c41e1e 45%, #8b0000 100%);
  --ball-blue: linear-gradient(145deg, #64b5f6 0%, #1565c0 50%, #0d47a1 100%);
  --ball-green: linear-gradient(145deg, #81c784 0%, #2e7d32 50%, #1b5e20 100%);
  /* 开奖球区：字号与球径比例（可读性优先） */
  --pub-orb-size: 56px;
  --pub-orb-num: clamp(1.05rem, 0.95rem + 0.35vw, 1.2rem);
  --pub-meta-wuxing: clamp(0.8125rem, 0.74rem + 0.25vw, 0.9375rem);
  --pub-meta-zodiac: clamp(0.75rem, 0.68rem + 0.22vw, 0.875rem);
  --pub-meta-gap: 0.28rem;
  --pub-ball-stack-gap: 0.625rem;
  --pub-sep-pad-bottom: 2.125rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.pub-body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--pub-bg);
  color: var(--pub-text);
}

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

.pub-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.pub-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pub-title .issue {
  color: var(--pub-accent);
}

.pub-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.pub-countdown {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pub-countdown span.label {
  color: var(--pub-muted);
  font-weight: 500;
  margin-right: 6px;
}

.pub-history {
  color: var(--pub-accent);
  text-decoration: none;
  font-size: 0.9375rem;
}

.pub-history:hover {
  text-decoration: underline;
}

.pub-refresh {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--pub-accent);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pub-refresh:hover {
  filter: brightness(1.08);
}

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

.pub-refresh--busy {
  pointer-events: none;
  opacity: 0.55;
}

.pub-refresh--busy::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 4px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -0.08em;
  animation: pub-refresh-spin 0.6s linear infinite;
}

.pub-card {
  background: var(--pub-card);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(44, 36, 22, 0.08);
  border: 1px solid rgba(122, 111, 99, 0.15);
  padding: 28px 20px 24px;
}

.pub-balls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 10px 12px;
}

.pub-ball {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pub-ball-stack-gap);
}

.pub-ball .orb {
  width: var(--pub-orb-size);
  height: var(--pub-orb-size);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: var(--pub-orb-num);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.38);
  box-shadow:
    inset 0 -5px 10px rgba(0, 0, 0, 0.28),
    inset 0 5px 12px rgba(255, 255, 255, 0.42),
    0 5px 14px rgba(0, 0, 0, 0.22);
  border: 2px solid rgba(255, 255, 255, 0.58);
}

.pub-ball .orb.red {
  background: var(--ball-red);
}

.pub-ball .orb.blue {
  background: var(--ball-blue);
}

.pub-ball .orb.green {
  background: var(--ball-green);
}

.pub-ball .orb.custom {
  background: linear-gradient(145deg, #94a3b8 0%, #64748b 50%, #475569 100%);
}

/* High-visibility pulse for a ball whose value just changed.
   Triggered from applyParts() / __applyPatch — unchanged balls keep
   their exact pixels and never enter this animation. */
@keyframes orb-flash {
  0% {
    box-shadow:
      0 0 0 0 rgba(250, 204, 21, 0.95),
      0 0 0 0 rgba(250, 204, 21, 0.6);
    transform: scale(1);
    filter: brightness(1.35) saturate(1.2);
  }
  25% {
    transform: scale(1.18);
    filter: brightness(1.5) saturate(1.3);
  }
  60% {
    box-shadow:
      0 0 0 18px rgba(250, 204, 21, 0),
      0 0 0 36px rgba(250, 204, 21, 0);
    transform: scale(1.05);
    filter: brightness(1.15) saturate(1.1);
  }
  100% {
    box-shadow:
      0 0 0 0 rgba(250, 204, 21, 0),
      0 0 0 0 rgba(250, 204, 21, 0);
    transform: scale(1);
    filter: none;
  }
}

.pub-ball .orb.orb--flash {
  animation: orb-flash 1.1s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform, box-shadow, filter;
}

.pub-ball-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pub-meta-gap);
  min-height: calc(var(--pub-meta-wuxing) * 1.35 + var(--pub-meta-zodiac) * 1.35 + var(--pub-meta-gap));
  justify-content: flex-start;
  text-align: center;
}

.pub-ball-meta .wuxing {
  font-size: var(--pub-meta-wuxing);
  color: var(--pub-text);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.08em;
}

.pub-ball-meta .zodiac {
  font-size: var(--pub-meta-zodiac);
  color: #645a50;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.06em;
}

.pub-sep {
  display: flex;
  align-items: center;
  padding-bottom: var(--pub-sep-pad-bottom);
  color: var(--pub-accent);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.pub-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(122, 111, 99, 0.2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.pub-next {
  margin: 0;
  font-size: 0.98rem;
  color: var(--pub-text);
  line-height: 1.5;
}

.pub-next .muted {
  color: var(--pub-muted);
}

.pub-btn-live {
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  background: var(--pub-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(196, 30, 30, 0.35);
}

.pub-btn-live:hover {
  filter: brightness(1.05);
}

/* --- Skeleton / loading state --- */

@keyframes pub-skeleton-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.pub-card.pub-loading .orb {
  background: linear-gradient(145deg, #d5cfc6 0%, #beb7ac 50%, #a89f94 100%) !important;
  color: transparent !important;
  text-shadow: none !important;
  animation: pub-skeleton-pulse 1.6s ease-in-out infinite;
}

.pub-card.pub-loading .pub-ball-meta span {
  color: transparent;
  background: #d5cfc6;
  border-radius: 3px;
  min-width: 1.5em;
  display: inline-block;
  animation: pub-skeleton-pulse 1.6s ease-in-out infinite;
}

.pub-card.pub-loading .pub-next strong,
.pub-card.pub-loading .pub-next .muted {
  color: transparent;
  background: #d5cfc6;
  border-radius: 3px;
  animation: pub-skeleton-pulse 1.6s ease-in-out infinite;
}

/* --- A11y focus ring --- */

.pub-refresh:focus-visible,
.pub-btn-live:focus-visible,
.pub-history:focus-visible {
  outline: 2px solid var(--pub-accent);
  outline-offset: 2px;
}

/* --- External link indicator --- */

.pub-history::after {
  content: "\2009\2197";
  font-size: 0.8em;
}

/* --- Responsive --- */

@media (max-width: 640px) {
  :root {
    --pub-orb-size: 46px;
    --pub-ball-stack-gap: 0.5rem;
    --pub-sep-pad-bottom: 1.625rem;
  }

  .pub-wrap {
    padding: 16px 12px 24px;
  }

  .pub-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .pub-title {
    font-size: 1.15rem;
  }

  .pub-card {
    padding: 20px 14px 18px;
    border-radius: 12px;
  }

  .pub-balls {
    gap: 8px 8px;
  }

  .pub-sep {
    font-size: 1.25rem;
  }

  .pub-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .pub-btn-live {
    align-self: stretch;
    text-align: center;
  }
}

