*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #021a0d;
  font-family: "Khmer OS Battambang", "Noto Sans Khmer", "Segoe UI", system-ui, sans-serif;
}

.viewport {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Deep emerald gradient backdrop for both desktop & mobile */
.emerald-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 92%, rgba(10, 148, 68, 0.62) 0%, rgba(4, 72, 34, 0.25) 26%, transparent 52%),
    radial-gradient(circle at 86% 52%, rgba(8, 128, 58, 0.52) 0%, rgba(4, 65, 30, 0.2) 28%, transparent 54%),
    radial-gradient(circle at 50% 48%, rgba(6, 90, 42, 0.35) 0%, transparent 56%),
    linear-gradient(135deg, #022413 0%, #01170b 52%, #022614 100%);
}

/* Responsive centered stage over full-bleed emerald background */
.stage {
  position: relative;
  z-index: 1;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  overflow: visible;
}

@media (max-width: 640px) {
  .stage {
    width: 100vw;
    height: 100dvh;
  }
}

/* Header: Brand Logo + 2-Line Title */
.header {
  position: absolute;
  top: 2.2%;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.brand-logo-img {
  width: 50%;
  height: auto;
  display: block;
  filter: drop-shadow(0 3px 6px rgba(15, 35, 85, 0.25));
}

.title-stack {
  margin-top: 1.5%;
  width: 62%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  filter: drop-shadow(0 4px 8px rgba(10, 45, 25, 0.3));
}

.title-line-1 {
  width: 48%;
  height: auto;
  display: block;
}

.title-line-2 {
  width: 100%;
  height: auto;
  display: block;
}

/* Wheel & Stand Assembly */
.wheel-section {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.wheel-rig {
  position: absolute;
  left: 50%;
  top: 26%;
  width: 66%;
  transform: translateX(-50%);
}

.wheel-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  z-index: 2;
}

/* Pedestal stand tucked directly behind bottom of wheel */
.stand-img {
  position: absolute;
  left: 50%;
  top: 85%;
  width: 100%;
  height: auto;
  transform: translateX(-50%);
  z-index: 1;
}

.gifts-left {
  position: absolute;
  left: -16%;
  top: 84%;
  width: 34%;
  height: auto;
  z-index: 3;
  filter: drop-shadow(0 6px 10px rgba(0, 20, 10, 0.45));
}

.gifts-right {
  position: absolute;
  right: -24%;
  top: 76%;
  width: 50%;
  height: auto;
  z-index: 3;
  filter: drop-shadow(0 6px 10px rgba(0, 20, 10, 0.45));
}

/* Rotating inner disc aligned to 6ea2921b...png inner ring (84.44% hole, 86.7% overlap) */
.wheel-rotator {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 86.7%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%) rotate(0deg);
  border-radius: 50%;
  background: #ffffff;
  overflow: hidden;
  z-index: 2;
  will-change: transform;
}

/* Rotate 4-green-wedge pattern +22.5deg so dividers fall on 0, 45, 90... */
.wheel-sectors-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transform: rotate(22.5deg) scale(1.01);
  pointer-events: none;
}

.wheel-prizes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.wheel-slice {
  position: absolute;
  left: 50%;
  top: 0;
  width: 44%;
  height: 50%;
  transform-origin: 50% 100%;
  pointer-events: none;
}

.slice-label {
  position: absolute;
  top: 8.5%;
  left: 50%;
  width: 78%;
  transform: translateX(-50%);
  font-size: clamp(7px, min(1.8vw, 1.02dvh), 10px);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.slice-icon {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 38%;
  height: 36%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.slice-icon-wide {
  width: 44%;
}

.wheel-slice.is-green .slice-label {
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 45, 10, 0.7);
}

.wheel-slice.is-white .slice-label {
  color: #0b6e22;
}

.wheel-ring-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 4;
  pointer-events: none;
  filter: drop-shadow(0 8px 16px rgba(10, 40, 25, 0.35));
}

.wheel-pointer {
  position: absolute;
  left: 50%;
  top: -3.5%;
  width: 11.5%;
  height: auto;
  transform: translateX(-50%);
  z-index: 5;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.38));
}

/* Spin CTA Button */
.play-btn-wrap {
  position: absolute;
  left: 50%;
  top: 69.5%;
  transform: translate(-50%, -50%);
  width: 44%;
  z-index: 6;
  display: flex;
  justify-content: center;
}

.img-btn {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  width: 100%;
  display: block;
  transition: transform 0.16s ease, filter 0.2s ease, opacity 0.2s ease;
  filter: drop-shadow(0 8px 14px rgba(10, 28, 75, 0.42));
}

.img-btn img {
  width: 100%;
  height: auto;
  display: block;
}

.img-btn:hover:not(:disabled) {
  transform: scale(1.04);
  filter: drop-shadow(0 10px 18px rgba(10, 28, 75, 0.52)) brightness(1.05);
}

.img-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.img-btn:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.play-btn:not(:disabled) {
  animation: pulseBtn 2s ease-in-out infinite;
}

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

/* Result Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(
    circle at 50% 44%,
    rgba(10, 148, 68, 0.56) 0%,
    rgba(3, 56, 26, 0.85) 48%,
    rgba(1, 22, 11, 0.94) 82%
  );
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow: hidden;
}

.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-sunburst {
  position: absolute;
  left: 50%;
  top: 44%;
  width: 240%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(
    from 0deg,
    rgba(38, 224, 114, 0.26) 0deg 10deg,
    rgba(16, 185, 84, 0) 10deg 22.5deg
  );
  mask-image: radial-gradient(circle, rgba(0, 0, 0, 0.95) 18%, rgba(0, 0, 0, 0.35) 55%, rgba(0, 0, 0, 0) 78%);
  -webkit-mask-image: radial-gradient(circle, rgba(0, 0, 0, 0.95) 18%, rgba(0, 0, 0, 0.35) 55%, rgba(0, 0, 0, 0) 78%);
  animation: rotateRays 24s linear infinite;
  pointer-events: none;
}

@keyframes rotateRays {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.modal-content {
  position: relative;
  z-index: 2;
  width: min(82vw, 340px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transform: scale(0.75) translateY(20px);
  opacity: 0;
  transition: transform 0.38s cubic-bezier(0.22, 1.25, 0.36, 1), opacity 0.28s ease;
}

.modal-overlay.is-open .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-card-wrap {
  position: relative;
  width: 86%;
  filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.45));
}

.modal-box-bg {
  width: 100%;
  height: auto;
  display: block;
}

.modal-card-body {
  position: absolute;
  left: 9%;
  right: 9%;
  top: 22%;
  bottom: 20%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.modal-state {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.modal-state[hidden] {
  display: none;
}

.modal-lose-emoji {
  width: 44%;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.16));
}

.modal-win-title {
  font-size: clamp(18px, 4.8vw, 24px);
  font-weight: 800;
  color: #16a34a;
}

.modal-win-coupon {
  width: 64%;
  height: auto;
  display: block;
  margin: 4px 0;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.modal-kh-msg {
  font-size: clamp(13px, 3.6vw, 17px);
  font-weight: 800;
  line-height: 1.45;
  color: #0b6e22;
}

.modal-action-btn {
  width: 72%;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45));
}

.modal-overlay.is-open .modal-action-btn {
  animation: modalBtnPulse 1.5s ease-in-out infinite;
}

.modal-overlay.is-open .modal-action-btn:hover {
  animation-play-state: paused;
  transform: scale(1.06);
}

.modal-overlay.is-open .modal-action-btn:active {
  animation: none;
  transform: scale(0.95);
}

@keyframes modalBtnPulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45)) brightness(1);
  }
  50% {
    transform: scale(1.07);
    filter: drop-shadow(0 12px 24px rgba(255, 115, 29, 0.7)) brightness(1.08);
  }
}

/* Larger wheel & CTA sizing on desktop */
@media (min-width: 641px) {
  .wheel-rig {
    top: 26%;
    width: 92%;
  }

  .slice-label {
    font-size: clamp(9px, min(2.5vw, 1.42dvh), 14px);
  }

  .play-btn-wrap {
    top: 86.5%;
    width: 58%;
  }

  .modal-content {
    width: min(82vw, 390px);
  }
}
