/* =========================================================
   ambm · sorteo (overlay 3D + tablero 3x3 + resultado)
   奖品位：视觉块（实物图 / 品牌卡 / 徽章）+ 加粗标题 + 副标
   ========================================================= */

body.modal-open { overflow: hidden; }

/* ------------------------------- overlay ------------------------------ */
.lottery-shell {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: radial-gradient(120% 100% at 50% 0%, #0b3f5bdd, #041e2dee);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  perspective: 1100px;
}
.lottery-shell[hidden] { display: none; }

.lottery-stage {
  --tilt-x: 2deg;
  --tilt-y: -1.5deg;
  position: relative;
  width: min(100%, 352px);
  padding: 4px;
  text-align: center;
  color: #fff;
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
  filter: drop-shadow(0 28px 23px #00182470);
  animation: lottery-appear .55s cubic-bezier(.2, .8, .2, 1) both;
  transition: transform .2s;
  outline: none;
}

.lottery-close {
  position: absolute; top: -6px; right: -4px; z-index: 5;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid #ffffff3d;
  background: #ffffff1f; color: #fff;
  font-size: 19px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
  transition: background .18s, transform .18s;
}
.lottery-close:hover { background: var(--red); transform: rotate(90deg); }

.lottery-kicker {
  margin: 0 0 4px;
  font-size: 9.5px; font-weight: 800; letter-spacing: 2.4px; text-transform: uppercase;
  color: var(--yellow);
  text-shadow: 0 2px 8px #00131f80;
}
.lottery-heading {
  margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.6px;
  text-shadow: 0 2px 8px #00131f80;
}
.lottery-lead {
  margin: 6px 0 14px; font-size: 12px; color: #d7ecf7;
  text-shadow: 0 2px 8px #00131f80;
}

.lottery-board { transform: translateZ(16px); }

/* -------------------------------- máquina ----------------------------- */
.machine {
  position: relative;
  padding: 11px;
  border-radius: 22px;
  background: linear-gradient(160deg, #24b0e8, #0885BE 44%, #04567a);
  border: 2px solid #7fd8f7;
  box-shadow:
    0 9px 0 #033d57,
    0 22px 36px #00182480,
    inset 0 1px 0 #ffffff66,
    inset 0 24px 28px -22px #ffffff55,
    inset 0 -14px 26px #00203366;
}

.lights {
  position: absolute; inset: 4px;
  border: 5px dotted #ffe000c4;
  border-radius: 17px;
  pointer-events: none;
  filter: drop-shadow(0 0 4px #ffe00066);
}
.machine.is-spinning .lights { animation: bulbs .42s steps(2, end) infinite; }
.machine.is-done .lights { border-color: #ffe000; filter: drop-shadow(0 0 8px #ffe00099); }

/* --------------------------------- grid -------------------------------- */
.grid {
  position: relative;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.prize {
  aspect-ratio: 1 / 1.18;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 5px 3px 6px;
  background: #fffdf8;
  border: 2px solid #ffffff;
  border-radius: 12px;
  color: var(--blue-ink);
  box-shadow: 0 3px 0 #033d5766;
  transition: background .07s, box-shadow .07s, transform .07s, border-color .07s;
  overflow: visible;
}

/* 视觉块：实物图 / 品牌卡 / 徽章 */
.prize-vis {
  display: grid; place-items: center;
  width: 100%; height: 46px; flex: 0 0 auto;
  margin-bottom: 1px;
}
.prize-vis svg { width: 30px; height: 30px; }

.vis-badge {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #eaf7fe, #d2ecfa);
  box-shadow: inset 0 -2px 0 #b7dff2, 0 2px 5px #0b3a521a;
  color: var(--blue);
}
.vis-badge svg { width: 24px; height: 24px; }

.prize-vis .vis-art { width: 54px; height: 54px; margin: -5px 0; filter: drop-shadow(0 2px 3px #0b3a5233); }
.prize-vis .vis-art--phone { width: auto; height: 52px; margin: -3px 0; }
.prize-vis .vis-art--headset { width: auto; height: 44px; margin: 0; }

/* 真图图标（去背 PNG）：高度定死，宽度自适应 */
.prize-vis .vis-photo {
  width: auto; height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px #0b3a5230);
}
.prize-vis .vis-photo--phone { height: 56px; }
.prize-vis .vis-photo--gift { height: 44px; }

.vis-img {
  width: 46px; height: 42px; object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 2px 6px #0b3a5226;
}

/* 品牌礼品卡 */
.vcard {
  position: relative;
  width: 74px; height: 42px;
  border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 3px 7px #0b3a5233;
}
.vcard i {
  font-style: normal; font-size: 7.5px; font-weight: 800;
  letter-spacing: .2px; opacity: .96;
}
.vcard b { font-size: 11px; font-weight: 800; letter-spacing: -.3px; color: var(--yellow); }
.vcard--ambm { background: linear-gradient(150deg, #1ea8e0, #0885BE 58%, #046E9C); }
.vcard--ambm::after {
  content: ""; position: absolute; right: -13px; top: -13px;
  width: 30px; height: 30px; background: var(--yellow); transform: rotate(35deg);
}
.vcard--walmart { background: linear-gradient(150deg, #0b7ad1, #004c97); }
.vcard--walmart::after {
  content: ""; position: absolute; right: -12px; top: -12px;
  width: 28px; height: 28px; background: #ffc220; transform: rotate(35deg);
}
.vcard--kolbi { background: linear-gradient(150deg, #00a651, #00703a); }
.vcard--kolbi b { color: #fff; }

.prize b {
  font-size: 10.5px; font-weight: 800; line-height: 1.15;
  text-align: center; letter-spacing: -.15px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.prize small {
  font-size: 8px; line-height: 1.15; color: #6f8b99; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}

.prize.is-active {
  background: #fff3b0;
  border-color: var(--red);
  transform: scale(1.03);
  box-shadow: 0 0 0 2px var(--red), 0 0 18px #ffe000cc;
  z-index: 1;
}
.prize.is-active .vis-badge { color: var(--red); background: #fff8d9; }

.prize.is-winner {
  background: var(--yellow);
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red), 0 0 26px #ffe000e6;
  animation: winner-pulse 1s ease-in-out infinite alternate;
  z-index: 2;
}
.prize.is-winner .vcard { box-shadow: 0 3px 8px #8a5a0033, 0 0 0 2px #ffffffcc; }

/* ------------------------------- botón jugar -------------------------- */
.play {
  position: relative;
  aspect-ratio: 1 / 1.18;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  background: linear-gradient(145deg, #ff3b4d, var(--red) 55%, #cf0d22);
  color: #fff;
  box-shadow: 0 4px 0 #a70b1c, inset 0 1px 0 #ffffff4d;
  transition: transform .08s, box-shadow .08s, filter .18s;
  padding: 4px;
}
/* 呼吸光环放在伪元素上，别抢按钮自身的 box-shadow（否则 :active 没反馈） */
.play::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 14px;
  box-shadow: 0 0 0 0 #f5213566;
  animation: play-halo 2.4s ease-out infinite;
  pointer-events: none;
}
.play:disabled::after { display: none; }
.play:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #a70b1c; }
.play:disabled { filter: saturate(.5) brightness(.9); cursor: default; }
.play-tri {
  width: 0; height: 0; margin-bottom: 3px;
  border-left: 12px solid #fff; border-top: 7px solid transparent; border-bottom: 7px solid transparent;
  filter: drop-shadow(0 1px 1px #00000040);
}
.play-label { font-size: 14px; font-weight: 800; letter-spacing: .2px; }
.play-sub { font-size: 8px; opacity: .82; letter-spacing: .2px; }

.play.is-spinning .play-tri { border-left-color: #ffffff5c; }

.lottery-note {
  margin: 14px 0 0; font-size: 10px; color: #b9d8e8;
  text-shadow: 0 2px 8px #00131f80;
}

/* ------------------------------- resultado ---------------------------- */
.dialog {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: #041e2da6;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.dialog[hidden] { display: none; }

.result-card {
  position: relative;
  display: flex; flex-direction: column;
  width: min(100%, 334px);
  max-height: calc(100svh - 32px);
  border-radius: 24px;
  background: var(--cream);
  box-shadow: 0 26px 50px -20px #001824cc;
  text-align: center;
  animation: lottery-appear .45s cubic-bezier(.2, .8, .2, 1) both;
  outline: none;
  overflow: hidden;
}

/* 内容区可滚，CTA 区固定在下沿 —— 小屏也不会把按钮滚没 */
.result-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 20px 6px;
  -webkit-overflow-scrolling: touch;
}

.result-foot {
  flex: 0 0 auto;
  padding: 10px 20px 16px;
  background: var(--cream);
  box-shadow: 0 -10px 16px -14px #0b3a5255;
}

.result-kicker {
  margin: 0 0 8px;
  font-size: 9.5px; font-weight: 800; letter-spacing: 2.4px; text-transform: uppercase;
  color: var(--blue);
}

.result-art { display: grid; place-items: center; height: 96px; margin-bottom: 10px; }

.gift {
  position: relative;
  width: 162px; height: 96px;
  border-radius: 12px;
  background: linear-gradient(150deg, #1ea8e0, var(--blue) 55%, var(--blue-deep));
  box-shadow: 0 12px 22px -12px #044a6999;
  color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  overflow: hidden;
}
.gift::after {
  content: "";
  position: absolute; right: -24px; top: -24px;
  width: 64px; height: 64px; background: var(--yellow);
  transform: rotate(35deg);
  box-shadow: 0 0 0 6px #044a6922;
  z-index: 0;
}
.gift > span { position: relative; z-index: 1; }
.gift-brand { font-size: 13px; font-weight: 800; letter-spacing: .4px; }
.gift-amount { font-size: 22px; font-weight: 800; letter-spacing: -.6px; color: var(--yellow); }
.gift-sub { font-size: 8.5px; letter-spacing: 1.6px; text-transform: uppercase; opacity: .85; }

.result-title { font-size: 20px; color: var(--red-deep); text-wrap: balance; }
.result-lead { margin: 6px 0 0; font-size: 12.5px; color: #44606E; }

.result-box {
  margin: 12px 0 12px;
  padding: 11px 12px;
  border-radius: 12px;
  background: #f5ecdb;
  font-size: 11.5px; line-height: 1.5; color: #5b5140;
  text-align: left;
}

/* 大奖池提示 */
.result-jackpot {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed #f0c419;
  background: #fffbe8;
  font-size: 11px; line-height: 1.45; color: #7a5c05;
  text-align: left;
}
.result-jackpot b { color: #a8790a; }

/* 兑奖三步 */
.result-steps {
  margin: 0 0 12px; padding: 0; list-style: none;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  text-align: center;
}
.result-steps li {
  padding: 7px 4px;
  border-radius: 10px;
  background: #f2f8fc;
  font-size: 8.5px; line-height: 1.25; color: #4a6875;
}
.result-steps span {
  display: grid; place-items: center;
  width: 18px; height: 18px; margin: 0 auto 4px;
  border-radius: 50%; background: var(--blue); color: #fff;
  font-size: 10px; font-weight: 800;
}

.result-fine { margin: 9px 0 0; font-size: 9.5px; color: #9aa9b1; }
.result-fine.is-alert { color: var(--red); font-weight: 700; font-size: 10.5px; }
.result-card .btn { min-height: 48px; }

/* -------------------------------- confeti ----------------------------- */
.confetti {
  position: absolute; inset: 0;
  overflow: hidden; pointer-events: none; z-index: 2;
  border-radius: inherit;
}
.confetti i {
  position: absolute; top: -14px;
  width: 7px; height: 12px; border-radius: 1px;
  animation: fall 1.9s ease-in both;
}
.confetti i:nth-child(3n) { background: var(--yellow); }
.confetti i:nth-child(even) { background: var(--red); }
.confetti i:nth-child(3n+1) { background: #7fd4f5; }

/* -------------------------------- anim -------------------------------- */
@keyframes lottery-appear {
  from { opacity: 0; transform: translateY(35px) rotateX(13deg) rotateY(-8deg) scale(.88); }
  to { opacity: 1; transform: translateY(0) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) scale(1); }
}

@keyframes play-halo {
  0% { box-shadow: 0 0 0 0 #f5213566; }
  70% { box-shadow: 0 0 0 10px #f5213500; }
  100% { box-shadow: 0 0 0 0 #f5213500; }
}

@keyframes winner-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.055); }
}

@keyframes bulbs {
  0% { border-color: #ffe000; filter: drop-shadow(0 0 7px #ffe000cc); }
  100% { border-color: #fffbd6; filter: drop-shadow(0 0 2px #ffffff66); }
}

@keyframes fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(340px) rotate(650deg); opacity: 0; }
}

/* ------------------------------ responsive ---------------------------- */
@media (max-height: 640px) {
  .lottery-stage { width: min(100%, 306px); }
  .lottery-heading { font-size: 21px; }
  .lottery-lead { margin-bottom: 10px; }
  .prize-vis { height: 30px; }
  .prize-vis svg { width: 22px; height: 22px; }
  .vis-badge { width: 30px; height: 30px; }
  .vis-badge svg { width: 18px; height: 18px; }
  .vis-img { width: 32px; height: 30px; }
  .prize-vis .vis-art { width: 34px; height: 34px; margin: 0; }
  .prize-vis .vis-photo { height: 30px; }
  .prize-vis .vis-photo--phone { height: 34px; }
  .prize-vis .vis-photo--gift { height: 28px; }
  .vcard { width: 60px; height: 30px; }
  .vcard i { font-size: 6px; }
  .vcard b { font-size: 9px; }
  .prize b { font-size: 9px; }
  .prize small { font-size: 7px; }
  .play-label { font-size: 12px; }
  .play-sub { font-size: 7px; }
  .play-tri { border-left-width: 10px; border-top-width: 6px; border-bottom-width: 6px; }
}

/* 小屏结果卡：内容压缩，按钮永远露在外面 */
@media (max-height: 700px) {
  .result-body { padding: 16px 16px 4px; }
  .result-kicker { margin-bottom: 6px; }
  .result-art { height: 68px; margin-bottom: 6px; }
  .gift { width: 126px; height: 72px; }
  .gift-brand { font-size: 11px; }
  .gift-amount { font-size: 18px; }
  .gift-sub { font-size: 7.5px; letter-spacing: 1.2px; }
  .result-title { font-size: 17.5px; }
  .result-lead { margin-top: 4px; font-size: 11.5px; }
  .result-box { margin: 9px 0; padding: 9px 10px; font-size: 10.8px; line-height: 1.45; }
  .result-jackpot { margin-bottom: 9px; padding: 8px 10px; font-size: 10px; line-height: 1.4; }
  .result-steps { gap: 5px; margin-bottom: 6px; }
  .result-steps li { font-size: 7.5px; padding: 5px 3px; }
  .result-steps span { width: 16px; height: 16px; margin-bottom: 3px; font-size: 9px; }
  .result-foot { padding: 8px 16px 12px; }
  .result-card .btn { min-height: 44px; font-size: 13.5px; }
  .result-fine { margin-top: 6px; font-size: 8.5px; }
}

/* 窄屏（<360px）再收一档：格子更窄，卡片与文字同步缩 */
@media (max-width: 359px) {
  .lottery-stage { width: 100%; }
  .machine { padding: 9px; }
  .grid { gap: 5px; }
  .prize-vis { height: 36px; }
  .prize-vis .vis-photo { height: 34px; }
  .prize-vis .vis-photo--phone { height: 40px; }
  .vcard { width: 66px; height: 34px; }
  .prize b { font-size: 9.5px; }
  .prize small { font-size: 7.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .lottery-stage { animation: none; transform: none; }
  .prize.is-winner, .machine.is-spinning .lights { animation: none; }
  .play::after { display: none; }
  .confetti { display: none; }
  .result-card { animation: none; }
}
