* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #888888;
  --text-muted: #b0b0b0;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.06);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-full: 50px;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
}

/* ==================== MAIN MENU SCREEN ==================== */
.app-container {
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.app-container.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
}

/* Top Navigation */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  padding-top: max(16px, env(safe-area-inset-top));
}

.nav-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease;
}

.nav-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.nav-btn:active {
  background: rgba(0, 0, 0, 0.08);
}

.nav-btn svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-primary);
  stroke-width: 2;
  fill: none;
}

/* Category Selector */
.category-selector {
  display: flex;
  justify-content: center;
  padding: 8px 24px 20px;
}

.category-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  border-radius: var(--radius-full);
  transition: background 0.2s ease;
}

.category-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.category-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--text-secondary);
  stroke-width: 2.5;
  fill: none;
  transition: transform 0.2s ease;
}

/* Card Carousel */
.carousel-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 0 20px;
  overflow: hidden;
}

.carousel {
  display: flex;
  gap: 20px;
  padding: 20px 40px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.carousel::-webkit-scrollbar {
  display: none;
}

.card {
  flex: 0 0 calc(100% - 80px);
  max-width: 340px;
  aspect-ratio: 3 / 4;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  scroll-snap-align: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.card:active {
  transform: scale(0.98);
}

.card-preview {
  width: 100%;
  height: 100%;
  position: relative;
}

.card-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Card Overlay */
.card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(to bottom,
      rgba(0, 0, 0, 0.15) 0%,
      transparent 30%,
      transparent 70%,
      rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
}

.card-date {
  color: white;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.card-date .day {
  font-size: 64px;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -2px;
}

.card-date .month {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 4px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-progress {
  flex: 1;
  max-width: 120px;
}

.progress-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 6px;
}

.progress-bar {
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: white;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.card-dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: all 0.2s ease;
}

.dot.active {
  background: white;
  width: 18px;
  border-radius: 3px;
}

/* Pagination Dots */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 20px 0 10px;
}

.page-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.3;
  transition: all 0.2s ease;
  cursor: pointer;
}

.page-dot.active {
  opacity: 1;
  background: var(--text-primary);
  width: 24px;
  border-radius: 4px;
}

/* Bottom Bar */
.bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.wallpaper-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--card-bg);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
}

.info-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-secondary);
  stroke-width: 1.5;
  fill: none;
}

.info-text {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.action-buttons {
  display: flex;
  gap: 12px;
}

.action-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.action-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

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

.action-btn svg {
  width: 20px;
  height: 20px;
  stroke: white;
  stroke-width: 2;
  fill: none;
}

.action-btn.secondary {
  background: var(--card-bg);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.action-btn.secondary svg {
  stroke: var(--text-primary);
}

/* ==================== FULLSCREEN WALLPAPER VIEW ==================== */
#wallpaper-view {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#wallpaper-view.active {
  opacity: 1;
  visibility: visible;
}

#wallpaper-container {
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Back Button */
.back-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  top: max(20px, env(safe-area-inset-top));
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0;
  visibility: hidden;
}

#wallpaper-view.active .back-btn {
  opacity: 1;
  visibility: visible;
}

.back-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.05);
}

.back-btn svg {
  width: 24px;
  height: 24px;
  stroke: white;
  stroke-width: 2;
  fill: none;
}

/* Wallpaper Info Overlay */
.wallpaper-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 30px 24px;
  padding-bottom: max(30px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

#wallpaper-view.active .wallpaper-overlay {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition-delay: 0.2s;
}

.wallpaper-overlay h2 {
  color: white;
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
}

.wallpaper-overlay p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

/* Responsive */
@media (max-width: 380px) {
  .card {
    flex: 0 0 calc(100% - 60px);
  }

  .carousel {
    padding: 20px 30px;
  }

  .wallpaper-info {
    padding: 10px 16px;
  }

  .info-value {
    font-size: 12px;
  }
}

@media (min-height: 800px) {
  .card {
    max-width: 360px;
  }
}

/* Desktop view */
@media (min-width: 481px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e5e7;
  }

  .app-container {
    height: 90vh;
    max-height: 900px;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.15);
    overflow: hidden;
  }

  #wallpaper-view {
    max-width: 480px;
    max-height: 90vh;
    height: 900px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 20px;
    overflow: hidden;
  }

  #wallpaper-view.active {
    transform: translate(-50%, -50%);
  }
}