/* ================= 弹珠抽奖 · 大屏样式 ================= */
* {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
}

html, body {
  width: 100%; height: 100%;
  background: #05001a;
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

#viewport {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0; /* 不用 inset 简写，兼容旧内核浏览器 */
}

#stage {
  position: absolute;
  left: 50%; top: 50%;
  width: 1920px; height: 1080px;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(124, 58, 237, .45), transparent 60%),
    radial-gradient(ellipse at 50% 110%, rgba(30, 64, 175, .5), transparent 55%),
    url("../assets/bg.jpg") center / cover no-repeat,
    linear-gradient(160deg, #1b0740 0%, #0b1035 55%, #2a0a52 100%);
  border: 4px solid #a855f7;
  border-radius: 20px;
  box-shadow: 0 0 60px rgba(168, 85, 247, .55), inset 0 0 120px rgba(88, 28, 135, .45);
  overflow: hidden;
}

/* ---------------- 顶部栏 ---------------- */
#topbar {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 72px;
  display: flex; align-items: center;
  padding: 0 28px;
  background: linear-gradient(180deg, rgba(20, 4, 48, .85), rgba(20, 4, 48, 0));
  z-index: 20;
}

.logo {
  flex: none;
  margin-right: auto; /* 顶栏其余元素靠右 */
  font-size: 34px; font-weight: 900; letter-spacing: 2px;
  background: linear-gradient(180deg, #fff6c9, #ffb300);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px rgba(255, 179, 0, .45);
  white-space: nowrap;
}
.logo span {
  background: linear-gradient(180deg, #c4b5fd, #7c3aed);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.marquee {
  display: flex; align-items: center;
  width: 560px; height: 44px;
  margin-right: 26px;
}
.marquee-label {
  flex: none;
  margin-right: 10px;
  font-size: 18px; font-weight: 700; color: #ffd54a;
  border: 1px solid rgba(255, 213, 74, .6);
  border-radius: 6px;
  padding: 4px 10px;
  white-space: nowrap;
}
.marquee-mask {
  flex: 1; height: 100%; overflow: hidden; position: relative;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee-inner {
  position: absolute; top: 50%; left: 0;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: 22px; font-weight: 700; color: #ffd54a;
  text-shadow: 0 0 12px rgba(255, 213, 74, .5);
  animation: marquee 20s linear infinite;
}
@keyframes marquee {
  0%   { transform: translate(100%, -50%); }
  100% { transform: translate(-100%, -50%); }
}

.top-actions {
  flex: none;
  display: flex; align-items: center;
}
.icon-btn {
  width: 46px; height: 46px;
  font-size: 24px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(124, 58, 237, .35);
  border: 2px solid rgba(167, 139, 250, .7);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.icon-btn + .icon-btn { margin-left: 12px; }
.icon-btn:hover { background: rgba(124, 58, 237, .65); transform: scale(1.08); }
.icon-btn:active { transform: scale(.94); }

/* ---------------- 奖品卡片 ---------------- */
.card {
  position: absolute;
  width: 136px; height: 152px;
  margin-left: -68px; margin-top: -76px;
  background: linear-gradient(165deg, #3b1a6e 0%, #1e0b3d 100%);
  border: 2px solid rgba(139, 92, 246, .85);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5), inset 0 0 18px rgba(124, 58, 237, .35);
  display: flex; flex-direction: column; align-items: center;
  padding-top: 10px;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
  z-index: 10;
}
.card .cimg {
  width: 104px; height: 96px;
  display: flex; align-items: center; justify-content: center;
}
.card .cimg img {
  max-width: 96%; max-height: 96%;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .55));
  pointer-events: none;
}
.card .clabel {
  margin-top: 6px;
  width: 112px; height: 30px; line-height: 30px;
  text-align: center;
  font-size: 19px; font-weight: 700; color: #e9d5ff;
  background: linear-gradient(180deg, rgba(17, 4, 38, .9), rgba(45, 16, 86, .9));
  border-radius: 6px;
  letter-spacing: 1px;
}
.card.active {
  transform: scale(1.14);
  border-color: #ffd54a;
  box-shadow: 0 0 26px rgba(255, 213, 74, .95), 0 0 60px rgba(255, 179, 0, .5);
  z-index: 12;
}
.card.win {
  animation: winPulse .55s ease-in-out infinite alternate;
  border-color: #ffd54a;
  z-index: 12;
}
@keyframes winPulse {
  from { transform: scale(1.12); box-shadow: 0 0 24px rgba(255, 213, 74, .9); }
  to   { transform: scale(1.22); box-shadow: 0 0 55px rgba(255, 179, 0, 1), 0 0 90px rgba(255, 179, 0, .6); }
}

/* ---------------- 方向箭头 ---------------- */
.arrow {
  position: absolute;
  font-size: 46px; font-weight: 900;
  color: rgba(103, 232, 249, .95);
  text-shadow: 0 0 12px rgba(34, 211, 238, .9), 0 0 30px rgba(34, 211, 238, .45);
  transform-origin: center;
  animation: arrowBlink .9s ease-in-out infinite alternate;
  z-index: 5;
  pointer-events: none;
}
@keyframes arrowBlink {
  from { opacity: .35; }
  to   { opacity: 1; }
}

/* ---------------- 中央弹珠机 ---------------- */
#machine {
  position: absolute;
  left: 632px; top: 318px;
  width: 396px;
  z-index: 8;
  filter: drop-shadow(0 14px 26px rgba(0, 0, 0, .55));
}
#machine.wiggle { animation: wiggle .5s ease-in-out; }
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-2.4deg); }
  45% { transform: rotate(2.2deg); }
  70% { transform: rotate(-1.4deg); }
  90% { transform: rotate(.8deg); }
}

/* ---------------- 控制面板 ---------------- */
#panel {
  position: absolute;
  left: 952px; top: 362px;
  width: 280px; height: 356px;
  background: linear-gradient(180deg, #4fc3f7 0%, #1e88e5 45%, #1565c0 100%);
  border: 3px solid #b3e5fc;
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5), inset 0 2px 10px rgba(255, 255, 255, .45);
  padding: 16px 18px;
  z-index: 9;
}
.panel-title {
  text-align: center;
  font-size: 20px; font-weight: 800; color: #fff;
  letter-spacing: 4px;
  text-shadow: 0 2px 4px rgba(13, 71, 161, .8);
  margin-bottom: 10px;
}
.count-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.pm {
  width: 56px; height: 58px;
  font-size: 34px; font-weight: 900; line-height: 1;
  color: #fff;
  background: linear-gradient(180deg, #ffb300, #f57c00);
  border: 3px solid #ffe082;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b25000, 0 6px 12px rgba(0, 0, 0, .35);
  text-shadow: 0 2px 2px rgba(0, 0, 0, .35);
}
.pm:active { transform: translateY(3px); box-shadow: 0 1px 0 #b25000; }
.count {
  width: 112px; height: 58px; line-height: 58px;
  text-align: center;
  font-size: 40px; font-weight: 900;
  font-family: "Consolas", "Courier New", monospace;
  color: #4dd0e1;
  background: linear-gradient(180deg, #061433, #0d2b5c);
  border: 3px inset rgba(77, 208, 225, .55);
  border-radius: 10px;
  text-shadow: 0 0 14px rgba(77, 208, 225, .9);
}
.quick {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 14px;
}
.quick button {
  width: 31%;
  height: 42px;
  margin-bottom: 8px;
  font-size: 20px; font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #29b6f6, #0277bd);
  border: 2px solid rgba(179, 229, 252, .9);
  border-radius: 8px;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
.quick button:hover { filter: brightness(1.18); }
.quick button:active { transform: scale(.95); }

#launch {
  width: 100%; height: 72px;
  font-size: 32px; font-weight: 900; letter-spacing: 6px;
  color: #fff;
  background: linear-gradient(180deg, #ffd54a 0%, #ff8f00 55%, #f4511e 100%);
  border: 3px solid #fff3c4;
  border-radius: 14px;
  cursor: pointer;
  text-shadow: 0 2px 4px rgba(120, 40, 0, .6);
  box-shadow: 0 6px 0 #a3320b, 0 10px 22px rgba(0, 0, 0, .4);
  animation: launchGlow 1.2s ease-in-out infinite alternate;
}
@keyframes launchGlow {
  from { filter: brightness(1); }
  to   { filter: brightness(1.22) drop-shadow(0 0 14px rgba(255, 179, 0, .9)); }
}
#launch:active { transform: translateY(4px); box-shadow: 0 2px 0 #a3320b; }
#launch:disabled {
  cursor: not-allowed;
  filter: grayscale(.75) brightness(.75);
  animation: none;
}

/* ---------------- 弹珠 ---------------- */
#ball {
  position: absolute;
  left: 0; top: 0;
  width: 64px; height: 64px;
  z-index: 40;
  display: none;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, .55)) drop-shadow(0 6px 8px rgba(0, 0, 0, .5));
  will-change: transform;
}

/* ---------------- 粒子画布 ---------------- */
#confetti {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 60;
  pointer-events: none;
}

/* ---------------- 中奖弹窗 ---------------- */
#modal {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 0, 26, .78);
}
#modal.hidden { display: none; }

.rays {
  position: absolute;
  left: 50%; top: 50%;
  width: 1600px; height: 1600px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(255, 236, 170, .1), transparent 60%); /* 旧内核回退 */
  background: repeating-conic-gradient(rgba(255, 236, 170, .09) 0deg 9deg, transparent 9deg 22deg);
  border-radius: 50%;
  animation: spin 14s linear infinite;
  pointer-events: none;
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.modal-panel {
  position: relative;
  width: 1020px; min-height: 560px;
  background: linear-gradient(170deg, #8e24aa 0%, #5c0f8a 45%, #38006b 100%);
  border: 5px solid #ea80fc;
  border-radius: 26px;
  box-shadow: 0 0 70px rgba(234, 128, 252, .65), inset 0 0 60px rgba(30, 0, 60, .65);
  padding: 110px 46px 60px;
  animation: popIn .45s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes popIn {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.celebrate {
  position: absolute;
  left: 50%; top: -196px;
  width: 440px;
  transform: translateX(-50%);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .5));
  pointer-events: none;
  z-index: 2;
}
.ribbon {
  position: absolute;
  left: 50%; top: -40px;
  transform: translateX(-50%);
  padding: 16px 96px;
  font-size: 46px; font-weight: 900; letter-spacing: 10px;
  color: #fff;
  background: linear-gradient(180deg, #ff6b6b 0%, #e53935 55%, #b71c1c 100%);
  border: 3px solid #ffcdd2;
  border-radius: 12px;
  text-shadow: 0 3px 5px rgba(90, 0, 0, .6);
  box-shadow: 0 8px 20px rgba(0, 0, 0, .45);
  white-space: nowrap;
  z-index: 3;
}
.ribbon::before, .ribbon::after {
  content: "";
  position: absolute;
  top: 100%;
  border-style: solid;
}
.ribbon::before {
  left: 14px;
  border-width: 14px 16px 0 0;
  border-color: #7f0000 transparent transparent transparent;
}
.ribbon::after {
  right: 14px;
  border-width: 14px 0 0 16px;
  border-color: #7f0000 transparent transparent transparent;
}

.results {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
}
.result-card {
  width: 270px;
  margin: 13px;
  background: linear-gradient(180deg, #fff8e1 0%, #ffe082 55%, #ffca28 100%);
  border: 3px solid #fff;
  border-radius: 18px;
  padding: 20px 16px 22px;
  text-align: center;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45), 0 0 30px rgba(255, 213, 74, .4);
  animation: cardUp .5s cubic-bezier(.34, 1.56, .64, 1) backwards;
}
.result-card:nth-child(2) { animation-delay: .08s; }
.result-card:nth-child(3) { animation-delay: .16s; }
.result-card:nth-child(4) { animation-delay: .24s; }
.result-card:nth-child(5) { animation-delay: .32s; }
@keyframes cardUp {
  from { transform: translateY(46px) scale(.8); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.rc-img {
  width: 190px; height: 180px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #a0512d, #5d2f0b);
  border-radius: 14px;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, .5);
}
.rc-img img { max-width: 86%; max-height: 86%; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .5)); }
.rc-level {
  margin-top: 14px;
  font-size: 32px; font-weight: 900; letter-spacing: 4px;
  color: #4e2600;
}
.rc-name {
  margin-top: 6px;
  font-size: 21px; font-weight: 700;
  color: #7a4a12;
}
.result-card.lose { filter: saturate(.55); }
.result-card.lose .rc-img { background: radial-gradient(circle at 35% 30%, #8d8d9e, #4a4a58); }
.result-card.lose .rc-level { color: #55556a; }
.result-card.lose .rc-name { color: #6a6a80; }

/* 多球结果：缩小卡片 */
.results.multi .result-card { width: 196px; padding: 12px 10px 14px; }
.results.multi .rc-img { width: 130px; height: 122px; }
.results.multi .rc-level { font-size: 23px; margin-top: 8px; letter-spacing: 2px; }
.results.multi .rc-name { font-size: 16px; }

.close {
  position: absolute;
  left: 50%; bottom: -84px;
  transform: translateX(-50%);
  width: 66px; height: 66px;
  font-size: 40px; font-weight: 400; line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, .08);
  border: 4px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  transition: .2s;
}
.close:hover { background: rgba(255, 255, 255, .25); transform: translateX(-50%) scale(1.1); }

/* ---------------- 全屏模式 ---------------- */
#viewport:fullscreen,
#viewport:-webkit-full-screen,
#viewport:-moz-full-screen,
#viewport:-ms-fullscreen {
  background: #05001a;
}
#stage { transition: box-shadow .3s ease; }

/* 全屏提示条 */
#fsTip {
  position: absolute;
  left: 50%; bottom: 26px;
  transform: translateX(-50%);
  z-index: 90;
  padding: 12px 34px;
  font-size: 20px; font-weight: 700; letter-spacing: 2px;
  color: #e9d5ff;
  background: rgba(30, 10, 60, .82);
  border: 1px solid rgba(167, 139, 250, .6);
  border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .5), 0 0 20px rgba(124, 58, 237, .35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s ease;
}
#fsTip.show { opacity: 1; }

/* ---------------- 扫码遥控浮窗 ---------------- */
#qrFloat {
  position: absolute;
  right: 30px; top: 560px;
  width: 220px;
  z-index: 70;
  background: rgba(20, 6, 46, .92);
  border: 2px solid rgba(167, 139, 250, .75);
  border-radius: 16px;
  padding: 14px 14px 10px;
  text-align: center;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .55), 0 0 24px rgba(124, 58, 237, .4);
  cursor: move;
  user-select: none;
}
#qrFloat.dragging { opacity: .85; border-color: #ffd54a; }
#qrFloat.hidden-qr { display: none; }
#qrFloat.qr-auto-hide { display: none; } /* 抽奖滚动期间自动隐藏，避免遮挡 */
.qr-title {
  font-size: 19px; font-weight: 800; color: #ffd54a;
  letter-spacing: 1px; margin-bottom: 10px;
  text-shadow: 0 0 12px rgba(255, 213, 74, .5);
}
#qrBox {
  width: 168px; height: 168px;
  margin: 0 auto;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  color: #333; font-size: 13px; word-break: break-all;
}
#qrBox img, #qrBox canvas, #qrBox table { display: block; max-width: 100%; }
.qr-tip { margin-top: 8px; font-size: 13px; color: #a78bfa; letter-spacing: 1px; }
