/* ═══════════════════════════════════════════════════════════════════════
   泊樂娛樂城 · sport539 號碼球開獎彈窗  (prefix: ball-)
   self-contained · 與其他站不共用 class / 配色 / 機制
   配色:樂透開獎白藍 + 金球
   ═══════════════════════════════════════════════════════════════════════ */

.ball-promo-active {
  padding-bottom: clamp(86px, 17vw, 128px);
}

.ball-footer-promo,
.ball-backdrop {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
}
.ball-footer-promo *,
.ball-backdrop * { box-sizing: border-box; }

/* ── Footer banner ────────────────────────────────────────────────── */
.ball-footer-promo {
  position: fixed;
  z-index: 2147483000;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  max-width: 980px;
  margin: 0 auto;
  border: 1px solid rgba(245, 210, 100, 0.45);
  border-radius: 10px;
  background: #06203f;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.44);
  overflow: hidden;
  transform: translateY(18px);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}
.ball-footer-promo.is-visible { transform: translateY(0); opacity: 1; }
.ball-footer-promo a { display: block; min-height: 64px; }
.ball-footer-promo img { display: block; width: 100%; height: auto; }

.ball-footer-text {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 14px 46px 14px 16px;
  color: #fff; font-size: 15px; font-weight: 700; flex-wrap: wrap; text-decoration: none;
}
.ball-footer-badge {
  padding: 2px 8px; border-radius: 999px; background: #ff4444;
  color: #fff; font-size: 12px; font-weight: 800;
}
.ball-footer-cta-pill {
  padding: 4px 12px; border-radius: 999px;
  background: linear-gradient(180deg, #ffe790, #ff9e2c);
  color: #160d05; font-size: 13px; font-weight: 900; white-space: nowrap;
}

.ball-footer-close,
.ball-close {
  position: absolute; z-index: 2; display: grid; place-items: center;
  width: 34px; height: 34px; border: 0; border-radius: 999px;
  color: #fff; background: rgba(0, 0, 0, 0.62); cursor: pointer;
  font-size: 22px; line-height: 1;
}
.ball-footer-close { top: 6px; right: 6px; }

/* ── Backdrop ─────────────────────────────────────────────────────── */
.ball-backdrop {
  position: fixed; inset: 0; z-index: 2147483001;
  display: grid; place-items: center; padding: 18px;
  background: rgba(4, 16, 34, 0.66);
  opacity: 0; transition: opacity 180ms ease;
}
.ball-backdrop.is-visible { opacity: 1; }

/* ── Card ─────────────────────────────────────────────────────────── */
.ball-card {
  position: relative;
  width: min(94vw, 420px);
  max-height: min(92vh, 760px);
  display: flex;
  flex-direction: column;
  color: #0c2342;
  border: 1px solid rgba(245, 210, 100, 0.5);
  border-radius: 16px;
  background:
    radial-gradient(circle at 82% 6%, rgba(245, 210, 100, 0.3), transparent 32%),
    linear-gradient(165deg, #ffffff 0%, #eaf2fc 48%, #d7e6f8 100%);
  box-shadow: 0 24px 70px rgba(8, 28, 60, 0.45);
  overflow: hidden;
  transform: translateY(14px) scale(0.985);
  transition: transform 180ms ease;
}
.ball-backdrop.is-visible .ball-card { transform: translateY(0) scale(1); }
.ball-close { top: 10px; right: 10px; }

/* ── Sticky header ────────────────────────────────────────────────── */
.ball-head {
  flex: none;
  padding: 16px 18px 12px;
  text-align: center;
  border-bottom: 1px solid rgba(12, 35, 66, 0.1);
  background: linear-gradient(180deg, #0d2c57, #103e76);
}
.ball-brand { font-size: 18px; font-weight: 900; letter-spacing: 0.5px; color: #ffe89b; }
.ball-sub   { margin-top: 4px; font-size: 12.5px; color: rgba(255, 255, 255, 0.85); }

/* ── Scrollable body ──────────────────────────────────────────────── */
.ball-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px 8px;
}
.ball-cap {
  text-align: center; font-size: 13px; line-height: 1.6;
  color: rgba(12, 35, 66, 0.8); margin-bottom: 12px;
}
.ball-cap b { color: #cc7a00; font-weight: 900; }
.ball-cap strong { color: #103e76; }

/* ── Lottery draw stage ───────────────────────────────────────────── */
.ball-stage { position: relative; display: grid; place-items: center; gap: 12px; }

/* drum / 開獎機 */
.ball-machine {
  position: relative;
  width: min(58vw, 200px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 50% 32%, rgba(255,255,255,0.95), rgba(207,228,250,0.6) 60%, rgba(160,196,238,0.5) 100%);
  border: 5px solid #103e76;
  box-shadow:
    inset 0 6px 18px rgba(255,255,255,0.7),
    inset 0 -10px 22px rgba(16,62,118,0.25),
    0 12px 26px rgba(8,28,60,0.3);
  overflow: hidden;
}
.ball-machine::after {
  /* draw spout at bottom */
  content: ""; position: absolute; bottom: -6px; left: 50%;
  width: 22%; height: 16%; transform: translateX(-50%);
  background: #103e76; border-radius: 0 0 10px 10px;
}
.ball-drum {
  position: relative; width: 86%; height: 86%; border-radius: 50%;
}
.ball-tumble {
  position: absolute;
  width: 26%; aspect-ratio: 1/1; border-radius: 50%;
  display: grid; place-items: center;
  font-size: clamp(10px, 3.2vw, 14px); font-weight: 900; color: #3a2400;
  background: radial-gradient(circle at 38% 30%, #fff3c4, #ffd84f 55%, #e7a823 100%);
  box-shadow: inset 0 -2px 4px rgba(120,80,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
  /* scatter the 8 balls around the drum */
  top: calc(50% - 13%); left: calc(50% - 13%);
  transform:
    rotate(calc(var(--bi) * 45deg)) translateY(-118%) rotate(calc(var(--bi) * -45deg));
}
.ball-machine.ball-shaking { animation: ballShake 0.28s linear infinite; }
.ball-machine.ball-shaking .ball-tumble { animation: ballTumble 0.6s ease-in-out infinite; }
@keyframes ballShake {
  0%,100% { transform: translate(0,0) rotate(0); }
  25%     { transform: translate(-3px,2px) rotate(-2deg); }
  75%     { transform: translate(3px,-2px) rotate(2deg); }
}
@keyframes ballTumble {
  0%,100% { margin-top: 0; }
  50%     { margin-top: -8%; }
}

/* flash 開出 588! */
.ball-flash {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(16px, 5vw, 22px); font-weight: 900; color: #fff;
  background: radial-gradient(circle, rgba(16,62,118,0.92), rgba(8,28,60,0.96));
  border-radius: 50%;
  opacity: 0; visibility: hidden; transform: scale(0.8);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
  text-shadow: 0 2px 8px rgba(255,216,79,0.6); z-index: 5;
}
.ball-flash.ball-flash-on { opacity: 1; visibility: visible; transform: scale(1); animation: ballFlashPulse 0.5s ease-in-out 1; }
@keyframes ballFlashPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* result slots */
.ball-slots { display: flex; gap: clamp(8px, 3vw, 14px); justify-content: center; }
.ball-slot {
  width: clamp(48px, 16vw, 64px); aspect-ratio: 1/1; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.7);
  border: 2px dashed rgba(16,62,118,0.4);
  box-shadow: inset 0 2px 6px rgba(16,62,118,0.12);
}
.ball-ball {
  width: 86%; aspect-ratio: 1/1; border-radius: 50%;
  display: grid; place-items: center;
  font-size: clamp(20px, 6.5vw, 30px); font-weight: 900; color: #3a2400;
  background: radial-gradient(circle at 38% 28%, #fff6cf, #ffd84f 52%, #e3a01c 100%);
  box-shadow: inset 0 -3px 6px rgba(120,80,0,0.32), 0 4px 10px rgba(227,160,28,0.4);
  opacity: 0; transform: translateY(-26px) scale(0.5);
}
.ball-ball.ball-landed {
  opacity: 1; transform: translateY(0) scale(1);
  transition: opacity 280ms ease, transform 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ball-draw {
  margin-top: 2px;
  padding: 10px 30px; border-radius: 999px;
  border: 0; cursor: pointer;
  color: #fff; font-size: clamp(15px, 4.5vw, 18px); font-weight: 900; letter-spacing: 0.06em;
  background: linear-gradient(180deg, #1456a6, #0d2c57);
  box-shadow: 0 6px 16px rgba(13, 44, 87, 0.4);
  transition: transform 120ms ease;
}
.ball-draw:hover:not(:disabled) { transform: scale(1.05); }
.ball-draw:disabled { cursor: default; opacity: 0.85; }

.ball-hint {
  margin-top: 2px; font-size: 12.5px; color: rgba(12, 35, 66, 0.6);
  transition: opacity 200ms ease;
}

/* ── Prize reveal ─────────────────────────────────────────────────── */
.ball-prize {
  position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; gap: 4px;
  background: radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.97), rgba(225, 238, 252, 0.98));
  border-radius: 12px;
  opacity: 0; visibility: hidden; transform: scale(0.9);
  transition: opacity 240ms ease, transform 240ms ease, visibility 240ms;
  z-index: 6;
}
.ball-prize.ball-shown { opacity: 1; visibility: visible; transform: scale(1); }
.ball-congrats { font-size: 16px; font-weight: 800; color: #103e76; }
.ball-amount {
  font-size: 64px; font-weight: 900; line-height: 1; color: #cc7a00;
  text-shadow: 0 4px 16px rgba(255, 216, 79, 0.5);
}
.ball-amount small { font-size: 22px; margin-left: 4px; }
.ball-prize-tag { margin-top: 6px; font-size: 13px; color: rgba(12, 35, 66, 0.82); }

/* ── Confetti ─────────────────────────────────────────────────────── */
.ball-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 7; }
.ball-conf { position: absolute; top: -16px; border-radius: 2px; }
@keyframes ballFall {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(360px) rotate(540deg); opacity: 0; }
}

/* ── 活動總覽 ─────────────────────────────────────────────────────── */
.ball-list-title {
  margin: 18px 0 10px; text-align: center; font-size: 13px; font-weight: 800;
  color: rgba(12, 35, 66, 0.7); letter-spacing: 0.04em;
}
.ball-acts { display: grid; gap: 8px; }
.ball-act {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(16, 62, 118, 0.16);
  background: rgba(255, 255, 255, 0.66);
}
.ball-act.ball-feat { border-color: rgba(245, 210, 100, 0.7); background: rgba(255, 244, 209, 0.7); }
.ball-badge {
  flex: none; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 999px; background: rgba(16, 62, 118, 0.12);
  font-size: 13px; font-weight: 800; color: #103e76;
}
.ball-act-main { flex: 1 1 auto; min-width: 0; }
.ball-act-label { font-size: 13.5px; font-weight: 800; color: #0c2342; }
.ball-tag {
  display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 999px;
  background: #f5d264; color: #3a2400; font-size: 10.5px; font-weight: 800;
}
.ball-act-desc { margin-top: 2px; font-size: 12px; color: rgba(12, 35, 66, 0.66); }
.ball-act-reward { flex: none; font-size: 22px; font-weight: 900; color: #cc7a00; }
.ball-act-reward small { font-size: 11px; color: rgba(12, 35, 66, 0.6); margin-left: 2px; }

/* ── Sticky footer ────────────────────────────────────────────────── */
.ball-foot {
  flex: none;
  padding: 12px 18px 14px;
  border-top: 1px solid rgba(16, 62, 118, 0.12);
  background: rgba(231, 240, 251, 0.92);
}
.ball-timer-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 10px; }
.ball-timer-label { font-size: 12px; color: rgba(12, 35, 66, 0.7); }
.ball-timer { display: flex; gap: 6px; }
.ball-tunit {
  min-width: 38px; padding: 4px 0; border-radius: 8px; text-align: center;
  background: #103e76; border: 1px solid rgba(16, 62, 118, 0.5);
}
.ball-tnum { font-size: 17px; font-weight: 900; color: #ffe89b; line-height: 1.1; }
.ball-tlbl { font-size: 10px; color: rgba(255, 255, 255, 0.78); }
.ball-timer-done { font-size: 14px; font-weight: 800; color: #c0392b; }

.ball-cta {
  display: flex; align-items: center; justify-content: center;
  min-height: 50px; border-radius: 10px;
  color: #160d05; text-decoration: none;
  background: linear-gradient(180deg, #ffe790, #ff9e2c);
  box-shadow: 0 10px 24px rgba(255, 157, 43, 0.35);
  font-size: 17px; font-weight: 900;
}
.ball-pulse { animation: ballPulse 1.1s ease-in-out 3; }
@keyframes ballPulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 10px 24px rgba(255, 157, 43, 0.3); }
  50%      { transform: scale(1.03); box-shadow: 0 14px 32px rgba(255, 157, 43, 0.55); }
}

.ball-terms { margin: 10px 0 0; font-size: 12px; color: rgba(12, 35, 66, 0.7); }
.ball-terms summary { cursor: pointer; color: rgba(12, 35, 66, 0.82); }
.ball-terms p { margin: 6px 0 0; line-height: 1.55; }
.ball-compliance { margin-top: 8px; text-align: center; font-size: 11.5px; color: rgba(12, 35, 66, 0.6); }

/* ── Mobile: bottom drawer ────────────────────────────────────────── */
@media (max-width: 520px) {
  .ball-promo-active { padding-bottom: clamp(72px, 23vw, 106px); }
  .ball-footer-promo { right: 8px; bottom: 8px; left: 8px; }
  .ball-backdrop { place-items: end center; padding: 0; }
  .ball-card {
    width: 100%;
    max-height: 94vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  .ball-backdrop.is-visible .ball-card { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .ball-footer-promo, .ball-backdrop, .ball-card, .ball-prize, .ball-pulse, .ball-conf,
  .ball-machine, .ball-tumble, .ball-ball, .ball-flash { transition: none; animation: none; }
}
