/* Global reset and safe-area support */
html,
body {
  margin: 0;
  padding: 0;
  /* Use small viewport height to account for mobile browser UI */
  height: 100svh;
  font-family: "Segoe UI", sans-serif;
  background: linear-gradient(to bottom, #0f0f0f 0%, #1a1a1a 100%);
  color: #fff;
  /* Prevent unintended scrollbars */
  overflow: hidden;
  /* Respect device notch/status-bar safe areas */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Wrapper fills full embed area */
#embed-wrapper {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Upload button styling */
.upload-label {
  padding: 14px 24px;
  background: linear-gradient(135deg, #ff4b2b, #ff416c);
  color: white;
  font-size: 16px;
  font-weight: bold;
  border-radius: 10px;
  cursor: pointer;
  animation: pulse 2s infinite;
  box-shadow: 0 0 20px rgba(255, 65, 108, 0.5);
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(255, 65, 108, 0.5);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 65, 108, 0.75);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 20px rgba(255, 65, 108, 0.5);
  }
}

/* Responsive canvas container - UPDATED FOR CENTERING */
.canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Canvas: centered in container - UPDATED FOR CENTERING */
#design-canvas {
  border-radius: 14px;
  background: transparent;
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.05);
  display: none;
  /* Remove width/height 100% and object-fit to allow JS to control sizing */
  margin: 0 auto;
}

/* Controls layout */
.control-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 18px;
}

/* Dot styling */
.dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s;
}
.dot:hover {
  transform: scale(1.1);
}
.dot.selected {
  border: 2px solid white;
}

/* Button and select defaults */
button,
select {
  background: #222;
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid #555;
  transition: all 0.2s ease;
}
button:hover,
select:hover {
  background: #333;
}

/* Toolbox layout */
#toolbox {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 14px 0;
}

/* Rotate modal overlay */
#rotate-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Demo preview container */
.demo-preview {
  text-align: center;
  margin: 20px 0;
}

/* Theme buttons row */
.theme-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.theme-btn {
  padding: 12px 20px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  background: #333;
  color: white;
  font-size: 14px;
}
.theme-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}
.theme-btn.active {
  border-color: #fff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Themed button gradients */
.theme-btn.christmas         { background: linear-gradient(135deg, #dc143c, #228b22); }
.theme-btn.christmas-night   { background: linear-gradient(135deg, #191970, #ffffff); }
.theme-btn.fourth            { background: linear-gradient(135deg, #b22222, #0047ab); }
.theme-btn.earth-day         { background: linear-gradient(135deg, #006994, #2e8b57); }
.theme-btn.st-patricks       { background: linear-gradient(135deg, #228b22, #ffffff); }
.theme-btn.valentines        { background: linear-gradient(135deg, #8b0000, #c71585); }
.theme-btn.rgb               { background: linear-gradient(135deg, #ff0000, #00ff00, #0000ff); }
.theme-btn.bright-white      { background: linear-gradient(135deg, #ffffff, #e6e6fa); color: #333; }
.theme-btn.warm-white        { background: linear-gradient(135deg, #fdf5e6, #deb887); color: #333; }

/* Demo house container for themes */
.demo-house-container {
  position: relative;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  aspect-ratio: 16 / 9;
  background: #191919;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 70vh;
  min-height: 420px;
}
.demo-house-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 24px;
}
.demo-house-img.hidden {
  opacity: 0;
  pointer-events: none;
}

#nextBtn {
  padding: 14px 24px !important;
  background: linear-gradient(135deg, #ff4b2b, #ff416c) !important;
  color: white !important;
  font-size: 16px !important;
  font-weight: bold !important;
  border-radius: 10px !important;
  cursor: pointer;
  animation: pulse 2s infinite;
  box-shadow: 0 0 20px rgba(255, 65, 108, 0.5) !important;
  border: none !important;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease !important;
}

#nextBtn:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 0 35px rgba(255, 65, 108, 0.8) !important;
  background: linear-gradient(135deg, #ff4b2b, #ff416c) !important;
}

#nextBtn:active {
  transform: translateY(0) !important;
  box-shadow: 0 0 15px rgba(255, 65, 108, 0.6) !important;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  #embed-wrapper {
    padding: 8px;
  }
  .theme-buttons {
    gap: 8px;
  }
  .theme-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  .demo-house-container {
    max-width: 100%;
    height: 50vh;
  }
}