* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #ff6b9d;
  --primary-light: #ffb3d9;
  --primary-dark: #ff4081;
  --secondary: #ffeaa7;
  --bg-gradient-start: #fff5f8;
  --bg-gradient-end: #ffe4f0;
  --text-dark: #2d2d2d;
  --text-light: #666;
  --white: #ffffff;
  --shadow: 0 10px 40px rgba(255, 107, 157, 0.15);
  --shadow-hover: 0 15px 60px rgba(255, 107, 157, 0.25);
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  min-height: 100vh;
  color: var(--text-dark);
  overflow-x: hidden;
  position: relative;
}

/* Background Decorations */
.background-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.sparkle {
  position: absolute;
  font-size: 1.5rem;
  animation: twinkle 3s ease-in-out infinite;
  opacity: 0.5;
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0.2;
    transform: scale(0.8) rotate(0deg);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2) rotate(180deg);
  }
}

.heart {
  position: absolute;
  bottom: -50px;
  font-size: 1.5rem;
  animation: float-up var(--duration) ease-in infinite;
  animation-delay: var(--delay);
  opacity: 0.4;
}

@keyframes float-up {
  0% {
    bottom: -50px;
    opacity: 0;
  }
  10% {
    opacity: 0.4;
  }
  90% {
    opacity: 0.4;
  }
  100% {
    bottom: calc(100vh + 50px);
    opacity: 0;
    transform: translateX(20px) rotate(360deg);
  }
}

/* Header */
.header {
  position: relative;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 107, 157, 0.1);
}

.logo {
  font-family: 'Pacifico', cursive;
  font-size: 1.6rem;
  color: var(--primary);
  font-weight: 400;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--white);
  border: 2px solid rgba(255, 107, 157, 0.2);
  border-radius: 25px;
  color: var(--text-dark);
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav-btn:hover {
  background: rgba(255, 107, 157, 0.05);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.nav-btn svg {
  width: 16px;
  height: 16px;
}

/* Frame Selection Bar */
.frame-selection {
  position: relative;
  z-index: 90;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 107, 157, 0.1);
  padding: 15px 40px;
}

.frame-selection-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.frame-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
}

.frame-options {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.frame-option {
  padding: 8px;
  background: var(--white);
  border: 3px solid rgba(255, 107, 157, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.frame-option:hover {
  border-color: var(--primary-light);
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(255, 107, 157, 0.2);
}

.frame-option.selected {
  border-color: var(--primary);
  background: rgba(255, 107, 157, 0.05);
  box-shadow: 0 5px 20px rgba(255, 107, 157, 0.3);
}

.frame-preview {
  width: 50px;
  height: 50px;
  border-radius: 8px;
}

.frame-none {
  background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
}

.frame-hearts {
  background:
    linear-gradient(white, white) padding-box,
    repeating-linear-gradient(45deg, #ff69b4 0px, #ff69b4 8px, #ffb6c1 8px, #ffb6c1 16px) border-box;
  border: 5px solid transparent;
}

.frame-flowers {
  background:
    linear-gradient(white, white) padding-box,
    repeating-linear-gradient(90deg, #ffb6c1 0px, #ffc0cb 15px, #ffb6c1 30px) border-box;
  border: 5px solid transparent;
}

.frame-stars {
  background:
    linear-gradient(white, white) padding-box,
    linear-gradient(135deg, #ffd700, #ffb347) border-box;
  border: 5px solid transparent;
}

.frame-rainbow {
  background:
    linear-gradient(white, white) padding-box,
    linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3) border-box;
  border: 5px solid transparent;
}

.frame-sparkles {
  background:
    linear-gradient(white, white) padding-box,
    repeating-linear-gradient(45deg, #fff 0px, #fff 5px, #ffd700 5px, #ffd700 10px) border-box;
  border: 5px solid transparent;
}

/* Main Content Layout */
.main-content {
  position: relative;
  z-index: 10;
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px;
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 40px;
  align-items: start;
}

/* Camera Section */
.camera-section {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.video-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  aspect-ratio: 4/3;
  background: #000;
  border-radius: 25px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.frame-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
}

/* Frame overlay styles */
.frame-overlay.hearts {
  border: 15px solid transparent;
  border-image: repeating-linear-gradient(45deg, #ff69b4 0px, #ff69b4 20px, #ffb6c1 20px, #ffb6c1 40px) 30;
}

.frame-overlay.flowers {
  border: 15px solid transparent;
  border-image: repeating-linear-gradient(90deg, #ffb6c1 0px, #ffc0cb 40px, #ffb6c1 80px) 30;
}

.frame-overlay.stars {
  border: 15px solid transparent;
  border-image: linear-gradient(135deg, #ffd700, #ffb347) 30;
}

.frame-overlay.rainbow {
  border: 15px solid transparent;
  border-image: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3) 30;
}

.frame-overlay.sparkles {
  border: 15px solid transparent;
  border-image: repeating-linear-gradient(45deg, #fff 0px, #fff 10px, #ffd700 10px, #ffd700 20px) 30;
}

.countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 107, 157, 0.9);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.countdown-overlay.active {
  display: flex;
}

#countdown-number {
  font-size: 8rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
  animation: countdown-pulse 1s ease-out;
}

@keyframes countdown-pulse {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.flash {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 20;
}

.flash.active {
  animation: flash-effect 0.3s ease-out;
}

@keyframes flash-effect {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.photo-counter {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 107, 157, 0.95);
  color: white;
  padding: 10px 20px;
  border-radius: 25px;
  font-weight: 600;
  font-size: 0.95rem;
  display: none;
  box-shadow: 0 5px 15px rgba(255, 107, 157, 0.4);
}

.photo-counter.active {
  display: block;
  animation: bounce-in 0.5s ease-out;
}

@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.status-message {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 107, 157, 0.95);
  color: white;
  padding: 12px 25px;
  border-radius: 25px;
  font-weight: 600;
  font-size: 1rem;
  display: none;
  box-shadow: 0 5px 20px rgba(255, 107, 157, 0.4);
  white-space: nowrap;
  z-index: 15;
}

.status-message.show {
  display: block;
  animation: fade-slide-up 0.3s ease-out;
}

@keyframes fade-slide-up {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  padding: 14px 30px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.5s, height 0.5s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn span {
  position: relative;
  z-index: 1;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  box-shadow: 0 8px 25px rgba(255, 107, 157, 0.3);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(255, 107, 157, 0.4);
}

.btn-large {
  padding: 18px 40px;
  font-size: 1.15rem;
}

.btn-secondary {
  background: linear-gradient(135deg, #ffd93d, #ffb347);
  color: var(--white);
  box-shadow: 0 8px 25px rgba(255, 179, 71, 0.3);
}

.btn-secondary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(255, 179, 71, 0.4);
}

.btn-special {
  background: linear-gradient(135deg, #a770ef, #cf8bf3, #fdb99b);
  color: var(--white);
  box-shadow: 0 8px 25px rgba(167, 112, 239, 0.4);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 8px 25px rgba(167, 112, 239, 0.4);
  }
  50% {
    box-shadow: 0 8px 35px rgba(167, 112, 239, 0.6);
  }
}

.btn-special:hover {
  transform: translateY(-3px);
}

.btn-outline {
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary-light);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.btn-outline:hover {
  background: rgba(255, 107, 157, 0.05);
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.instructions {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  border-radius: 15px;
  padding: 18px 25px;
  color: var(--text-light);
  font-size: 0.95rem;
  text-align: center;
  border: 1px solid rgba(255, 107, 157, 0.2);
}

/* Photostrip Sidebar */
.photostrip-sidebar {
  background: var(--white);
  border-radius: 25px;
  padding: 30px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 20px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 2px solid rgba(255, 107, 157, 0.1);
}

.sidebar-header h3 {
  font-size: 1.3rem;
  color: var(--text-dark);
  font-weight: 700;
}

.photo-count {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
}

.photostrip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 25px;
}

.photo-slot {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #fff9fb, #fff0f5);
  border: 3px solid rgba(255, 107, 157, 0.2);
  border-radius: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.photo-slot:hover {
  border-color: var(--primary-light);
  transform: scale(1.05);
}

.slot-number {
  font-size: 3rem;
  font-weight: 700;
  color: rgba(255, 107, 157, 0.2);
}

.photo-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.photo-slot.captured {
  animation: photo-appear 0.5s ease-out;
}

@keyframes photo-appear {
  0% {
    transform: scale(0.8) rotate(-5deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.05) rotate(2deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.download-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.download-section .btn {
  width: 100%;
  justify-content: center;
}

/* Sticker Modal */
.sticker-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  animation: fade-in 0.3s ease-out;
}

.sticker-modal.show {
  display: flex;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.sticker-modal-content {
  background: var(--white);
  border-radius: 30px;
  padding: 40px;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.3);
  animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.close-button {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 45px;
  height: 45px;
  font-size: 2.5rem;
  background: rgba(255, 107, 157, 0.1);
  border: none;
  border-radius: 50%;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.3s ease;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-button:hover {
  background: rgba(255, 107, 157, 0.2);
  transform: rotate(90deg);
}

.sticker-modal-content h2 {
  color: var(--text-dark);
  text-align: center;
  margin-bottom: 25px;
  font-size: 1.8rem;
  font-weight: 700;
}

.photo-selector {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.photo-select-btn {
  padding: 10px 20px;
  background: rgba(255, 107, 157, 0.1);
  border: 2px solid rgba(255, 107, 157, 0.3);
  border-radius: 20px;
  color: var(--text-dark);
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.photo-select-btn:hover {
  background: rgba(255, 107, 157, 0.2);
  transform: translateY(-2px);
}

.photo-select-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary);
  color: white;
  box-shadow: 0 5px 20px rgba(255, 107, 157, 0.4);
}

.edit-canvas-container {
  position: relative;
  margin: 0 auto 25px;
  width: fit-content;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(255, 107, 157, 0.2);
  border: 3px solid rgba(255, 107, 157, 0.1);
}

#edit-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.sticker-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.sticker-element {
  position: absolute;
  font-size: 3rem;
  cursor: move;
  pointer-events: all;
  user-select: none;
  transition: transform 0.1s ease;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.3));
}

.sticker-element:hover {
  transform: scale(1.15);
}

.sticker-library {
  margin-bottom: 25px;
}

.sticker-library h3 {
  color: var(--text-dark);
  margin-bottom: 15px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
  padding: 15px;
  background: rgba(255, 107, 157, 0.03);
  border-radius: 15px;
  border: 1px solid rgba(255, 107, 157, 0.1);
}

.sticker-btn {
  width: 65px;
  height: 65px;
  font-size: 2.5rem;
  background: var(--white);
  border: 2px solid rgba(255, 107, 157, 0.2);
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sticker-btn:hover {
  background: rgba(255, 107, 157, 0.1);
  transform: scale(1.2);
  box-shadow: 0 5px 20px rgba(255, 107, 157, 0.3);
  z-index: 10;
}

.sticker-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.sticker-actions .btn {
  flex: 1;
}

/* Responsive */
@media (max-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .photostrip-sidebar {
    position: relative;
    top: 0;
  }

  .photostrip {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 768px) {
  .header {
    padding: 15px 20px;
  }

  .logo {
    font-size: 1.3rem;
  }

  .nav-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
  }

  .frame-selection {
    padding: 12px 20px;
  }

  .frame-selection-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .frame-options {
    width: 100%;
    justify-content: center;
  }

  .frame-preview {
    width: 45px;
    height: 45px;
  }

  .main-content {
    padding: 20px;
  }

  .video-container {
    border-radius: 20px;
  }

  .controls {
    gap: 10px;
  }

  .btn {
    padding: 13px 25px;
    font-size: 0.95rem;
  }

  .btn-large {
    padding: 15px 30px;
    font-size: 1rem;
  }

  .photostrip-sidebar {
    padding: 25px;
  }

  .photostrip {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .photo-slot {
    min-height: 120px;
  }

  #countdown-number {
    font-size: 5rem;
  }

  .status-message {
    font-size: 0.9rem;
    padding: 10px 20px;
    bottom: 15px;
  }

  .sticker-modal-content {
    padding: 30px 20px;
    margin: 15px;
    max-height: 95vh;
  }

  .sticker-modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
  }

  .sticker-grid {
    grid-template-columns: repeat(auto-fill, minmax(55px, 1fr));
    gap: 8px;
  }

  .sticker-btn {
    width: 55px;
    height: 55px;
    font-size: 2.2rem;
  }

  .sticker-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .header {
    flex-direction: row;
    padding: 12px 15px;
  }

  .logo {
    font-size: 1.1rem;
  }

  .nav-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    gap: 4px;
  }

  .nav-btn svg {
    width: 14px;
    height: 14px;
  }

  .frame-preview {
    width: 40px;
    height: 40px;
  }

  .main-content {
    padding: 15px;
  }

  .btn {
    padding: 12px 20px;
    font-size: 0.9rem;
  }

  .btn-large {
    padding: 14px 25px;
    font-size: 0.95rem;
  }

  .photostrip-sidebar {
    padding: 20px;
  }

  .sidebar-header h3 {
    font-size: 1.1rem;
  }

  .photo-slot {
    min-height: 100px;
  }

  .slot-number {
    font-size: 2.5rem;
  }

  #countdown-number {
    font-size: 4rem;
  }

  .status-message {
    font-size: 0.85rem;
    padding: 10px 18px;
    bottom: 10px;
  }

  .sticker-modal-content {
    padding: 25px 15px;
  }

  .sticker-grid {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  }

  .sticker-btn {
    width: 50px;
    height: 50px;
    font-size: 2rem;
  }

  /* Reduce animations */
  .sparkle:nth-child(n+3),
  .heart:nth-child(n+2) {
    display: none;
  }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .nav-btn,
  .frame-option,
  .photo-select-btn,
  .sticker-btn {
    touch-action: manipulation;
  }

  .btn {
    min-height: 48px;
  }

  .sticker-btn {
    min-width: 48px;
    min-height: 48px;
  }

  .sticker-element {
    min-width: 50px;
    min-height: 50px;
  }
}
