/* Reset */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: 'Helvetica Neue', Arial, 'Noto Sans TC', sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

/* ========== Loading Screen ========== */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  color: #f4c5cd;
  font-size: 1.2rem;
  margin-bottom: 20px;
  letter-spacing: 2px;
}

.loading-bar-container {
  width: 60%;
  max-width: 300px;
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ec7eaa, #f4c5cd);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ========== 9:16 Scene Container ========== */
#scene {
  position: relative;
  aspect-ratio: 9 / 16;
  width: 100%;
  max-height: 100vh;
  height: 100vh;
  max-width: calc(100vh * 9 / 16);
}

/* ========== Video ========== */
#main-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

/* ========== Button Overlay ========== */
/* Overlay must match the video's visible area (9:16 contain) */
#button-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 100%;
  pointer-events: none;
  z-index: 10;
}

#button-overlay.hidden {
  display: none;
}

/* ========== Draw Button ========== */
.btn-wrapper {
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  width: 42%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  z-index: 10;
}

.btn-wrapper.hidden {
  display: none;
}

/* Light glow effect behind button */
.light-effect {
  position: absolute;
  width: 100%;
  height: auto;
  pointer-events: none;
  animation: pulse-glow 2s ease-in-out infinite;
  z-index: 0;
}

@keyframes pulse-glow {

  0%,
  100% {
    opacity: 0.6;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

/* Normal button image */
.overlay-btn {
  width: 100%;
  display: block;
  position: relative;
  z-index: 1;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.overlay-btn:active {
  transform: scale(0.95);
}

/* Hover state (stacked on top of normal) */
.hover-btn {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.btn-wrapper:hover .hover-btn,
.btn-wrapper:active .hover-btn {
  opacity: 1;
}

/* ========== Result Area ========== */
#result-area {
  position: absolute;
  bottom: 32%;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  pointer-events: auto;
  cursor: pointer;
  z-index: 10;
}

#result-area.hidden {
  display: none;
}

.use-now-btn {
  display: block;
  width: 100%;
}

.use-now-btn img {
  width: 100%;
  display: block;
}

/* ========== Already Drawn Popup ========== */
#already-drawn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#already-drawn.hidden {
  display: none;
}

.popup-card {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 40px 24px 32px;
  width: 75%;
  height: 150px;
  min-width: 320px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.popup-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 20px;
  height: 20px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1;
}

.popup-close-btn img {
  width: 100%;
  height: 100%;
}

.already-drawn-text {
  color: #3e3a39;
  font-family: 'Taipei Sans TC Beta', 'Noto Sans TC', sans-serif;
  font-size: 1.1rem;
  font-weight: 900;
  text-align: center;
  line-height: 2;
  letter-spacing: 1px;
}


@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

/* ========== Discount Info ========== */
.discount-info {
  text-align: center;
  padding: 5px;
}

.discount-info.hidden {
  display: none;
}

.discount-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.discount-code-value {
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
  letter-spacing: 2px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.4);
}

.copy-btn {
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px;
  font-size: 0.55rem;
  cursor: pointer;
  pointer-events: auto;
  background: none;
}

.copy-btn img {
  width: 15px;
  height: 15px;
}

.discount-min-text {
  color: #f4c5cd;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.discount-expire-text {
  color: rgba(244, 197, 205, 0.7);
  font-size: 0.75rem;
}

/* ========== Speaker Button ========== */
#speaker-btn {
  position: absolute;
  top: 5%;
  right: 5%;
  z-index: 60;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

#speaker-btn:hover {
  background: rgba(0, 0, 0, 0.6);
}

#speaker-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: invert(1);
}

/* ========== Utility ========== */
.hidden {
  display: none !important;
}