/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  overscroll-behavior: none;
  background-color: transparent;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #3a2a0a;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  /* Make sure Body takes up full height but can grow */
}

/* New standalone element for stretched background */
.background-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100dvw;
  /* 100% of dynamic viewport width */
  height: 100dvh;
  /* 100% of dynamic viewport height */
  z-index: -1;
  background-image: url('assets/phonebg.webp');
  background-size: 100% 100%;
  /* Forces image to stretch to edges */
  background-position: center;
  background-repeat: no-repeat;
}

.hidden {
  display: none !important;
}

.hidden-mobile {
  display: none !important;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: max(0.8vh, env(safe-area-inset-top));
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.logo-combined {
  width: min(280px, 65vw);
  height: auto;
  margin-top: -0.5vh;
  display: block;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding: 0 12px;
  min-height: 0;
  position: relative;
  z-index: 1;
  /* allow flex shrinking */
}

/* ===== TITLE ===== */
.page-title {
  font-size: clamp(1.2rem, 3.5vw, 2.2rem);
  font-weight: 800;
  text-align: center;
  color: #2a1a00;
  margin: 0.5vh 0 0.8vh;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

/* ===== COUNTDOWN TIMER ===== */
.countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-bottom: 0.8vh;
  flex-shrink: 0;
}

.countdown-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #7a1a1a;
  border-radius: 8px;
  padding: 0.4vh 10px 0.6vh;
  min-width: 56px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.countdown-label {
  font-size: 0.6rem;
  color: #f0d0d0;
  text-transform: capitalize;
  letter-spacing: 0.5px;
  margin-bottom: 1px;
}

.countdown-value {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 800;
  color: #ffffff;
  line-height: 1;
}

.countdown-colon {
  font-size: clamp(1.2rem, 3.5vw, 2rem);
  font-weight: 800;
  color: #7a1a1a;
  margin: 8px 1px 0;
}

/* ===== DIVIDER ===== */
.section-divider {
  width: 90%;
  border: none;
  border-top: 1px solid rgba(150, 120, 60, 0.3);
  margin-bottom: 0.8vh;
  flex-shrink: 0;
}

/* ===== DRAW CARDS WRAPPER ===== */
.draw-cards-wrapper {
  flex: 1;
  /* Wrapper takes available space */
  display: flex;
  flex-direction: column;
  gap: 0.8vh;
  /* Reduce gap on mobile to save vertical pixels */
  width: 100%;
  max-width: 600px;
  min-height: 0;
  justify-content: center;
  /* Center the cards if there's extra space */
  align-items: center;
  /* Ensures children don't stretch unconditionally */
}

/* ===== DRAW CARDS ===== */
.draw-card {
  position: relative;
  width: auto;
  /* Let aspect ratio determine width from the available height */
  height: auto;
  aspect-ratio: 618 / 350;
  /* Base ratio of the Figma asset */
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  /* Helps internal alignment */
  flex: 1 1 0;
  /* Consume exactly available vertical remaining height split equally 3 ways */
  max-width: 100%;
  /* Prevent stretching wider than parent width limit */
  max-height: 100%;
  container-type: inline-size;
  /* Treat as a scalable design canvas */
}

.draw-card-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.draw-card-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  /* Do not crop the design ever */
  pointer-events: none;
}

.draw-card-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2cqw;
  text-align: center;
}

.draw-label {
  font-size: 3.4cqw;
  font-weight: 700;
  margin-bottom: 0;
}

/* Draw 1 & 2 labels: gold */
.draw-label-1,
.draw-label-2 {
  color: #FBCE03;
}

/* Draw 3 label: dark brown */
.draw-label-3 {
  color: #723005;
}

.draw-prize-name {
  font-size: 5cqw;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.draw-prize-amount {
  font-size: 8.5cqw;
  font-weight: 900;
  color: #ffd700;
  margin-bottom: 0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  line-height: 1.1;
}

.draw-winners {
  font-size: 3.2cqw;
  font-weight: 600;
  color: #fff;
  margin-bottom: 1.5cqw;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Draw button */
.draw-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  z-index: 3;
  position: relative;
  margin-top: 1cqw;
  /* Slightly less margin to help with squishing */
}

.draw-btn:not(.is-disabled):hover {
  transform: scale(1.05);
}

.draw-btn:not(.is-disabled):active {
  transform: scale(0.97);
}

/* Shake Animation */
@keyframes shake {
  0% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px) rotate(-3deg);
  }

  50% {
    transform: translateX(5px) rotate(3deg);
  }

  75% {
    transform: translateX(-5px) rotate(-3deg);
  }

  100% {
    transform: translateX(0);
  }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

.draw-btn-img {
  width: auto;
  height: min(25cqw, 3.8vh);
  /* Significantly reduced size to match mockup and prevent overflow */
  display: block;
  transition: opacity 0.8s ease;
}

/* Lock icon — BEHIND the overlay so it gets blurred + tinted */
.draw-lock-icon {
  position: absolute;
  top: 50%;
  right: 2cqw;
  transform: translateY(-50%) rotate(15deg);
  width: 20cqw;
  height: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1;
  transition: opacity 1.5s ease, visibility 1.5s ease;
}

.draw-card.is-locked .draw-lock-icon {
  opacity: 0.95;
  visibility: visible;
}

/* Full-card dark overlay with blur */
.draw-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 2;
  pointer-events: none;
  border-radius: 12px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.5s ease, visibility 1.5s ease;
}

.draw-card.is-locked::after {
  opacity: 1;
  visibility: visible;
}

/* Removed empty .draw-card-content block */



/* ===== RESULTS MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: #f5c842;
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  padding: 16px 20px 32px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.35s ease;
}

.modal-handle,
.modal-subtitle,
.modal-title {
  flex-shrink: 0;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.modal-handle {
  width: 120px;
  height: 4px;
  background: #ffffff;
  border-radius: 2px;
  margin: 0 auto 16px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.2s ease;
  z-index: 10;
}

.modal-close img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-close:hover {
  transform: scale(1.1);
}

.modal-subtitle {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: #a0220a;
  margin-bottom: 2px;
}

.modal-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #1a1a1a;
  margin-bottom: 20px;
}

/* Codes grid */
.modal-codes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  overflow-y: auto;
  max-height: 380px;
  /* ~5 rows for max 10 cards on mobile */
  padding-right: 4px;
}

.modal-codes-grid::-webkit-scrollbar {
  width: 6px;
}

.modal-codes-grid::-webkit-scrollbar-track {
  background: transparent;
}

.modal-codes-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
}

.code-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.code-card-label {
  font-size: 1rem;
  font-weight: 700;
  color: #3a2a0a;
  margin-bottom: 3px;
}

.code-card-value {
  font-size: 0.85rem;
  font-weight: 800;
  color: #a0220a;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 0.4vh 12px max(1.5vh, env(safe-area-inset-bottom));
  font-size: 0.65rem;
  color: #8a7a5a;
  flex-shrink: 0;
}

/* ==========================
   DESKTOP STYLES (>768px)
   ========================== */
@media (min-width: 769px) {

  .hidden-mobile {
    display: block !important;
  }

  .background-container {
    background-image: url('assets/bgpc.webp');
  }

  body {
    position: relative;
  }

  /* Gate arch overlay for desktop split into 3 images */
  .desktop-gate {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
      url('assets/pillarhead.webp'),
      url('assets/pillarleft.webp'),
      url('assets/pillarright.webp');
    background-position:
      top center,
      left bottom,
      right bottom;
    background-size:
      100% auto,
      max(120px, calc(50vw - 640px)) 100%,
      max(120px, calc(50vw - 640px)) 100%;
    background-repeat: no-repeat;
  }

  .main-content {
    max-width: 1400px;
    /* Wider to accommodate 3 horizontal cards */
    padding: 2vh 40px;
  }

  .header {
    padding-top: 1vh;
    z-index: 2;
    position: relative;
  }

  .logo-combined {
    width: 400px;
  }

  .page-title {
    font-size: 2.4rem;
    margin: 0.6vh 0 1vh;
  }

  .countdown-cell {
    min-width: 80px;
    padding: 0.5vh 16px 0.8vh;
  }

  .countdown-value {
    font-size: 2.4rem;
  }

  .countdown-label {
    font-size: 0.75rem;
  }

  .countdown-colon {
    font-size: 2rem;
  }

  .draw-cards-wrapper {
    flex-direction: row;
    max-width: 1300px;
    gap: 24px;
    height: auto;
    /* Fix constraint on desktop */
    margin: auto 0;
    align-items: center;
    justify-content: center;
  }

  .draw-card {
    height: auto;
    /* Width dictates height via aspect-ratio */
    width: 100%;
    /* Desktop cards should occupy horizontal maxes */
    max-height: none;
    flex: 1 1 0;
    /* Let them flex equally side by side up to max limit */
    max-width: 400px;
    /* Don't let them get infinitely wide */
    aspect-ratio: 618 / 350;
  }

  /* Modal: centered popup on desktop */
  .modal-overlay {
    align-items: center;
  }

  .modal {
    border-radius: 24px;
    max-width: 900px;
    max-height: 80vh;
    padding: 24px 32px 36px;
  }

  .modal-handle {
    display: none;
  }

  .modal-codes-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .modal-title {
    font-size: 1.8rem;
  }

  .code-card {
    padding: 16px 14px;
  }

  .code-card-value {
    font-size: 1.1rem;
  }
}

/* ===== SMALL MOBILE (≤375px) ===== */
@media (max-width: 375px) {
  .logo-combined {
    width: 240px;
  }

  .countdown-cell {
    min-width: 48px;
    padding: 0.3vh 6px 0.5vh;
  }
}

/* ===== LOADER ===== */
.loader-wrapper {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: #f5e6c8;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.8s ease, transform 0.8s ease, visibility 0.8s ease;
  transform: scale(1);
}

.loader-wrapper.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.1);
  /* Slight zoom as it fades out reveals the UI smoothly */
  pointer-events: none;
}

.loader-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(122, 26, 26, 0.1);
  border-top-color: #7a1a1a;
  border-bottom-color: #7a1a1a;
  border-radius: 50%;
  animation: spinnerOuter 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 0 15px rgba(122, 26, 26, 0.4), inset 0 0 10px rgba(122, 26, 26, 0.2);
}

.loader-spinner-inner {
  width: 30px;
  height: 30px;
  border: 4px solid rgba(251, 206, 3, 0.2);
  border-left-color: #FBCE03;
  /* Tata Gold accent */
  border-right-color: #FBCE03;
  border-radius: 50%;
  animation: spinnerInner 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite reverse;
  box-shadow: 0 0 10px rgba(251, 206, 3, 0.5);
}

@keyframes spinnerOuter {
  0% {
    transform: rotate(0deg) scale(0.9);
    box-shadow: 0 0 10px rgba(122, 26, 26, 0.3);
  }

  50% {
    transform: rotate(180deg) scale(1.1);
    box-shadow: 0 0 25px rgba(122, 26, 26, 0.6), inset 0 0 15px rgba(122, 26, 26, 0.3);
  }

  100% {
    transform: rotate(360deg) scale(0.9);
    box-shadow: 0 0 10px rgba(122, 26, 26, 0.3);
  }
}

@keyframes spinnerInner {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}