@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Montserrat", sans-serif;
}

body {
  /* Green noise background approximation if bg.png is not perfect */
  background: url("bg.svg");
  background-blend-mode: overlay;
  background-size: cover;
  background-position: center;
  /* background-repeat: no-repeat; */
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start; /* Allow scrolling if needed */
  overflow-x: hidden;
}

.main-container {
  width: 100%;
  max-width: 480px; /* Mobile width constraint */
  position: relative;
  padding-bottom: 50px;
  margin-top: 20px; /* Added spacing from top */
}

/* Logos (Restored) */
#hero {
  max-height: 80px; /* Smaller to match mockup */
  width: auto;
  display: block;
  margin: 0 auto;
}
#hero-container {
  margin-bottom: 15px;
}
.logo-left,
.logo-right {
  display: none; /* Hide if still present */
}

/* Title */
.title-image {
  max-width: 80%;
  height: auto;
  margin-top: 10px;
}

.title-section {
  text-align: center;
  margin-bottom: 20px;
}

.title-text {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 2.5rem;
  color: #ffffff;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  margin: 0;
  line-height: 1.1;
  letter-spacing: 2px;
}

/* Form Inputs */
.custom-input {
  background-color: #ffffff !important;
  border: none !important;
  border-radius: 12px !important;
  padding: 15px 20px !important;
  font-size: 1rem !important;
  color: #333 !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}
.custom-input::placeholder {
  color: #aaa;
}
.custom-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px #fff, 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Camera Container - Slightly Larger */
.camera-container {
  width: 120px !important;
  max-width: 120px !important;
  min-width: 120px !important;
  height: 155px !important;
  max-height: 155px !important;
  min-height: 155px !important;
  margin: 0 auto !important;
  padding: 0 !important;
  position: relative;
  overflow: hidden;
  background: #000;
  border-radius: 50%; /* Makes it oval/ellipse */
  display: block;
}

video,
#photo-preview,
#canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror effect */
  display: block;
}
#photo-preview {
  transform: scaleX(1) !important;
}

/* Camera Button Overlay at Bottom */
.camera-btn-overlay {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
}

/* Face Overlay Logic */
.face-overlay {
  position: absolute;
  display: none; /* Hide face guide overlay */
}

.face-hole {
  display: none; /* Not needed anymore */
}

/* Countdown */
#countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 80px;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  z-index: 20;
  display: none;
}

/* Camera Button */
.btn-camera {
  background-color: #2d9c86; /* Teal to match theme */
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%; /* Circular */
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(45, 156, 134, 0.5);
  transition: transform 0.2s;
}
.btn-camera:active {
  transform: scale(0.9);
}

/* Upload Button */
.btn-upload {
  background-color: #2d9c86; /* Teal Green */
  color: white;
  font-weight: 700;
  font-size: 1.2rem;
  padding: 12px 0;
  width: 100%; /* Full width or fixed width? Design shows wide button */
  width: 200px;
  border-radius: 30px;
  border: 2px solid #fff; /* White border as seen in some designs? check image. Image: Solid green/teal button, text "Upload". */
  box-shadow: 0 4px 15px rgba(45, 156, 134, 0.4);
  transition: all 0.3s;
}
.btn-upload:hover {
  background-color: #268572;
  transform: translateY(-2px);
}

/* Thank You Card */
.p3 {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh; /* Take up most of viewport height */
  padding: 20px;
}

.success-card {
  background-color: #1c8263;
  border-radius: 20px;
  border: 4px solid #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 100%;
}
.bold-name {
  font-weight: 800;
  color: #ffde59; /* Yellow highlight text */
}

/* Responsive */
@media (max-width: 550px) {
  .camera-container {
    max-width: 90%;
    height: auto;
    aspect-ratio: 120 / 155; /* Maintain oval aspect ratio */
  }
}

@media (max-height: 800px) {
  .camera-container {
    height: 28vh;
  }
}

/* --- NEW STYLES FOR PAGE 1 & 2 --- */

/* Photo Slots */
.photo-slot {
  width: 100px;
  height: 100px;
  background-color: #000;
  border-radius: 50%; /* Circle */
  border: 4px solid #fff;
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 0.8rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
.photo-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-slot .placeholder-text {
  position: absolute;
  z-index: 5;
}

/* Page 2 Layout */
.p2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 80vh;
}

.p2 .content-wrapper {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Character Preview (Page 2) - Asset-Driven Sizing */
.character-preview-container {
  width: 100%;
  max-width: 280px;
  height: 450px;
  position: relative;
  margin: 20px auto 30px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.character-preview-container::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  height: 18px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 50%;
  filter: blur(6px);
}

.preview-layer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

/* Accessories Layer - Top (hats, etc) */
.acc-layer {
  top: 60px;
  width: 140px;
  height: auto;
  z-index: 6;
}

/* Face Layer - Circular, positioned in head area */
.face-layer {
  top: 110px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  overflow: hidden; /* MASK */
  z-index: 5;
}

.face-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* POTONG BUKAN TARIK */
  border-radius: 50%;
}

/* Body Layer - Center */
.body-layer {
  top: 215px;
  /* width: 240px; */
  height: auto;
  z-index: 3;
}

/* Hand Layer - Overlays body */
.hand-layer {
  top: 215px;
  width: 270px;
  height: auto;
  z-index: 4;
}

/* Leg Layer - Bottom */
.leg-layer {
  bottom: 5px;
  /* width: 240px; */
  height: auto;
  z-index: 2;
}

/* Outfit Selector */
.outfit-selector-wrapper {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.outfit-selector {
  background-color: #ffffff;
  border-radius: 20px;
  padding: 15px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 15px;
}
.btn-category {
  border: 1px solid #ddd;
  border-radius: 20px;
  background: #f9f9f9;
  color: #555;
  padding: 5px 15px;
  font-size: 0.9rem;
  white-space: nowrap;
  margin-right: 5px;
  transition: all 0.2s;
}
.btn-category.active,
.btn-category:active {
  background-color: #f8c35e; /* Orange/Yellow */
  color: #fff;
  border-color: #f8c35e;
}

/* Control Buttons (Bottom of P2) */
.btn-control-circle {
  background-color: #2d9c86;
  width: 64px;
  height: 64px;
  font-size: 1.3rem;
}

.btn-control-circle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(45, 156, 134, 0.5);
}

.btn-control-circle:active {
  transform: translateY(0);
}

.btn-control-large {
  width: 78px;
  height: 78px;
  font-size: 1.6rem;
}

/* Page 2 Specific Styles */
.outfit-selector-wrapper {
  max-width: 400px;
}

.category-nav {
  background-color: #ffffff;
  border-radius: 20px;
  padding: 14px 20px;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.12);
  margin-bottom: 15px;
}

.category-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #2d9c86;
  letter-spacing: 1px;
}

.btn-nav-arrow {
  background: transparent;
  border: none;
  color: #2d9c86;
  font-size: 1.3rem;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-nav-arrow:hover {
  transform: scale(1.15);
}

.btn-nav-arrow:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

/* Item Grid Container */
.item-grid {
  display: flex;
  flex-direction: row;
  gap: 12px;
  padding: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  /* Prevent items from shrinking */
  flex-wrap: nowrap;
}

/* Custom scrollbar styling */
.item-grid::-webkit-scrollbar {
  height: 6px;
}

.item-grid::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.item-grid::-webkit-scrollbar-thumb {
  background: #2d9c86;
  border-radius: 10px;
}

.item-grid::-webkit-scrollbar-thumb:hover {
  background: #268572;
}

.item-option {
  background: #fff;
  border-radius: 14px;
  padding: 10px;
  border: 3px solid transparent;
  min-width: 70px;
  max-width: 70px;
  height: 70px;
  flex-shrink: 0; /* Prevent shrinking */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.item-option img {
  width: 90%;
  height: 90%;
  object-fit: contain;
}

.item-option:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.item-option.selected {
  background-color: #fff3c4;
  border-color: #f4c430;
}
