/* ======================================
   인생세컷 - Multi-Theme Photo Booth
   ====================================== */

@font-face {
  font-family: "LanaPixel";
  src: url("assets/fonts/LanaPixel.ttf") format("truetype");
}

/* ======================================
   Theme Variables
   ====================================== */

/* Theme 1: Y2K Pink */
[data-theme="y2k-pink"] {
  --primary: #ff5c8a;
  --primary-light: #ffd6e0;
  --primary-dark: #e91e63;
  --secondary: #c39bd3;
  --accent: #ffb6c1;
  --bg-gradient: linear-gradient(135deg, #ffd6e0 0%, #ffb6c1 50%, #e8daef 100%);
  --card-bg: rgba(255, 255, 255, 0.9);
  --text-primary: #4a3c4a;
  --text-secondary: #8b7b8b;
  --shadow-color: rgba(255, 92, 138, 0.3);
  --btn-gradient: linear-gradient(135deg, #ff8fab 0%, #ff5c8a 100%);
  --glow-color: #ff5c8a;
}

/* Theme 2: Retro Film */
[data-theme="retro-film"] {
  --primary: #8b4513;
  --primary-light: #deb887;
  --primary-dark: #654321;
  --secondary: #d2691e;
  --accent: #f4a460;
  --bg-gradient: linear-gradient(135deg, #f5deb3 0%, #deb887 50%, #d2b48c 100%);
  --card-bg: rgba(255, 248, 240, 0.95);
  --text-primary: #3e2723;
  --text-secondary: #6d4c41;
  --shadow-color: rgba(139, 69, 19, 0.3);
  --btn-gradient: linear-gradient(135deg, #d2691e 0%, #8b4513 100%);
  --glow-color: #d2691e;
}

/* Theme 3: Neon Cyberpunk */
[data-theme="neon-cyber"] {
  --primary: #00ffff;
  --primary-light: #1a1a2e;
  --primary-dark: #ff00ff;
  --secondary: #7b68ee;
  --accent: #39ff14;
  --bg-gradient: linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 50%, #16213e 100%);
  --card-bg: rgba(10, 10, 26, 0.95);
  --text-primary: #00ffff;
  --text-secondary: #7b68ee;
  --shadow-color: rgba(0, 255, 255, 0.5);
  --btn-gradient: linear-gradient(135deg, #ff00ff 0%, #00ffff 100%);
  --glow-color: #00ffff;
}

/* Theme 4: Minimal White */
[data-theme="minimal-white"] {
  --primary: #2c3e50;
  --primary-light: #ecf0f1;
  --primary-dark: #1a252f;
  --secondary: #95a5a6;
  --accent: #3498db;
  --bg-gradient: linear-gradient(135deg, #ffffff 0%, #f8f9fa 50%, #ecf0f1 100%);
  --card-bg: rgba(255, 255, 255, 0.98);
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --shadow-color: rgba(44, 62, 80, 0.15);
  --btn-gradient: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
  --glow-color: #3498db;
}

/* Theme 5: Vintage Polaroid */
[data-theme="vintage-polaroid"] {
  --primary: #704214;
  --primary-light: #fff8dc;
  --primary-dark: #4a2c0a;
  --secondary: #8b7355;
  --accent: #cd853f;
  --bg-gradient: linear-gradient(135deg, #fffaf0 0%, #faf0e6 50%, #fff8dc 100%);
  --card-bg: rgba(255, 250, 240, 0.98);
  --text-primary: #4a2c0a;
  --text-secondary: #8b7355;
  --shadow-color: rgba(112, 66, 20, 0.25);
  --btn-gradient: linear-gradient(135deg, #cd853f 0%, #8b4513 100%);
  --glow-color: #daa520;
}

/* Theme 6: Graduation Gold */
[data-theme="graduation-gold"] {
  --primary: #ffd700;
  --primary-light: #1a1a2e;
  --primary-dark: #b8860b;
  --secondary: #c0c0c0;
  --accent: #daa520;
  --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 50%, #1a1a2e 100%);
  --card-bg: rgba(26, 26, 46, 0.95);
  --text-primary: #ffd700;
  --text-secondary: #c0c0c0;
  --shadow-color: rgba(255, 215, 0, 0.4);
  --btn-gradient: linear-gradient(135deg, #ffd700 0%, #b8860b 100%);
  --glow-color: #ffd700;
}

/* Theme 7: Pastel Dream */
[data-theme="pastel-dream"] {
  --primary: #b19cd9;
  --primary-light: #e6e6fa;
  --primary-dark: #9370db;
  --secondary: #ffb7c5;
  --accent: #98fb98;
  --bg-gradient: linear-gradient(
    135deg,
    #ffe4e1 0%,
    #e6e6fa 33%,
    #f0fff0 66%,
    #fff0f5 100%
  );
  --card-bg: rgba(255, 255, 255, 0.9);
  --text-primary: #6b5b7a;
  --text-secondary: #9b8aa6;
  --shadow-color: rgba(177, 156, 217, 0.3);
  --btn-gradient: linear-gradient(
    135deg,
    #ffb7c5 0%,
    #b19cd9 50%,
    #87ceeb 100%
  );
  --glow-color: #b19cd9;
}

/* Theme 8: Korean Traditional */
[data-theme="korean-traditional"] {
  --primary: #c41e3a;
  --primary-light: #fff5e6;
  --primary-dark: #8b0000;
  --secondary: #1e4d8c;
  --accent: #228b22;
  --bg-gradient: linear-gradient(135deg, #fff5e6 0%, #faebd7 50%, #f5f5dc 100%);
  --card-bg: rgba(255, 250, 240, 0.95);
  --text-primary: #2f1810;
  --text-secondary: #5d4037;
  --shadow-color: rgba(196, 30, 58, 0.25);
  --btn-gradient: linear-gradient(135deg, #c41e3a 0%, #8b0000 100%);
  --glow-color: #c41e3a;
}

/* Theme 9: Photogray */
[data-theme="photogray"] {
  --primary: #6b6b6b;
  --primary-light: #e8e8e8;
  --primary-dark: #3a3a3a;
  --secondary: #9e9e9e;
  --accent: #b0b0b0;
  --bg-gradient: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 50%, #d5d5d5 100%);
  --card-bg: rgba(255, 255, 255, 0.97);
  --text-primary: #333333;
  --text-secondary: #777777;
  --shadow-color: rgba(100, 100, 100, 0.2);
  --btn-gradient: linear-gradient(135deg, #888888 0%, #555555 100%);
  --glow-color: #999999;
}

/* Theme 10: Cute Pop */
[data-theme="cute-pop"] {
  --primary: #ff6b9d;
  --primary-light: #fff0f5;
  --primary-dark: #e84393;
  --secondary: #a29bfe;
  --accent: #ffeaa7;
  --bg-gradient: linear-gradient(135deg, #fff0f5 0%, #f0e6ff 33%, #e6fff0 66%, #fff5e6 100%);
  --card-bg: rgba(255, 255, 255, 0.92);
  --text-primary: #6c5ce7;
  --text-secondary: #a29bfe;
  --shadow-color: rgba(255, 107, 157, 0.3);
  --btn-gradient: linear-gradient(135deg, #ff6b9d 0%, #a29bfe 50%, #74b9ff 100%);
  --glow-color: #ff6b9d;
}

/* ======================================
   Base Styles
   ====================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "LanaPixel", "Noto Sans KR", -apple-system, BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--text-primary);
  user-select: none;
  transition: background 0.5s ease;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* ======================================
   Screen Management
   ====================================== */
.screen {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: none;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  box-sizing: border-box;
}

.screen.active {
  display: flex;
  flex: 1;
  opacity: 1;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ======================================
   Buttons
   ====================================== */
.primary-btn {
  background: var(--btn-gradient);
  color: white;
  border: none;
  padding: 18px 48px;
  font-size: 20px;
  font-family: inherit;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 8px 25px var(--shadow-color), 0 4px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 2px;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.primary-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s;
}

.primary-btn:hover::before {
  left: 100%;
}

.primary-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 35px var(--shadow-color), 0 6px 15px rgba(0, 0, 0, 0.15);
}

.primary-btn:active {
  transform: translateY(0) scale(0.98);
}

.primary-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.secondary-btn {
  background: transparent;
  color: var(--primary);
  border: 3px solid var(--primary);
  padding: 14px 36px;
  font-size: 16px;
  font-family: inherit;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.secondary-btn:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

/* ======================================
   Start Screen
   ====================================== */
#start-screen {
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 10px;
}

.start-container {
  text-align: center;
  width: 100%;
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10px;
}

.overlay {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  padding: 30px 35px;
  border-radius: 25px;
  box-shadow: 0 20px 60px var(--shadow-color);
  animation: floatUp 0.8s ease-out;
  max-width: 850px;
  width: 95%;
  margin: 10px auto;
}

@keyframes floatUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overlay h1 {
  font-size: 48px;
  background: var(--btn-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  letter-spacing: 4px;
}

.overlay .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Theme Selection */
.theme-selection {
  margin-bottom: 25px;
}

.theme-selection h3 {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 100%;
  margin: 0 auto;
}

.theme-card {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 3px solid transparent;
  display: flex;
  flex-direction: column;
}

.theme-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 15px 40px var(--shadow-color);
}

.theme-card.selected {
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 0 0 3px var(--glow-color), 0 15px 40px var(--shadow-color);
}

.theme-card .theme-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

/* contain으로 변경: 미리보기의 실루엣/텍스트/장식이 잘리지 않게 전체 노출 */
.theme-card .theme-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 9px 9px 0 0;
  display: block;
}

.theme-card .theme-name {
  flex-shrink: 0;
  padding: 9px 6px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  color: white;
  font-size: 13px;
  letter-spacing: 0.2px;
  text-align: center;
  font-weight: 700;
  border-radius: 0 0 9px 9px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Individual Theme Card Styles */
.theme-card[data-theme="y2k-pink"] {
  background: linear-gradient(135deg, #ffd6e0, #ffb6c1, #e8daef);
}

.theme-card[data-theme="retro-film"] {
  background: linear-gradient(135deg, #f5deb3, #deb887, #d2b48c);
}

.theme-card[data-theme="neon-cyber"] {
  background: linear-gradient(135deg, #0a0a1a, #1a1a2e, #16213e);
}

.theme-card[data-theme="neon-cyber"] .theme-name {
  text-shadow: 0 0 10px #00ffff;
}

.theme-card[data-theme="minimal-white"] {
  background: linear-gradient(135deg, #ffffff, #f8f9fa, #ecf0f1);
  border: 1px solid #ddd;
}

.theme-card[data-theme="vintage-polaroid"] {
  background: linear-gradient(135deg, #fffaf0, #faf0e6, #fff8dc);
}

.theme-card[data-theme="graduation-gold"] {
  background: linear-gradient(135deg, #1a1a2e, #2d2d44, #1a1a2e);
}

.theme-card[data-theme="graduation-gold"] .theme-preview {
  color: #ffd700;
  text-shadow: 0 0 20px #ffd700;
}

.theme-card[data-theme="pastel-dream"] {
  background: linear-gradient(135deg, #ffe4e1, #e6e6fa, #f0fff0, #fff0f5);
}

.theme-card[data-theme="korean-traditional"] {
  background: linear-gradient(135deg, #fff5e6, #faebd7, #f5f5dc);
}

.theme-card[data-theme="special-event"] {
  background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
}

.theme-card[data-theme="photogray"] {
  background: linear-gradient(135deg, #e8e8e8, #cfcfcf, #b8b8b8);
}

.theme-card[data-theme="cute-pop"] {
  background: linear-gradient(135deg, #fff0f5, #ffe0f0, #ffd1ec);
}

/* Settings Row */
.settings-row {
  display: flex;
  justify-content: center;
  gap: 25px;
  margin-bottom: 35px;
  flex-wrap: wrap;
}

.setting-group {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.05);
  padding: 15px 25px;
  border-radius: 30px;
}

.setting-group label {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.setting-group select,
.setting-group input {
  background: var(--card-bg);
  border: 2px solid var(--primary-light);
  padding: 8px 14px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.setting-group select:focus,
.setting-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--shadow-color);
}

.setting-group input[type="number"] {
  width: 70px;
  text-align: center;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 25px;
  padding: 5px;
}

.mode-toggle button {
  background: transparent;
  border: none;
  padding: 10px 24px;
  border-radius: 20px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
}

.mode-toggle button.active {
  background: var(--btn-gradient);
  color: white;
  box-shadow: 0 2px 10px var(--shadow-color);
}

/* ======================================
   Countdown Screen
   ====================================== */
#countdown-screen,
#shooting-screen {
  background: #000;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

#countdown-screen.active,
#shooting-screen.active {
  animation: none !important;
  transition: none !important;
  opacity: 1 !important;
}

.camera-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.camera-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  z-index: 1;
}

.camera-preview-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 2;
  display: none;
}

.countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
}

#countdown-number {
  font-size: 200px;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 60px var(--glow-color), 0 0 120px var(--primary);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.countdown-message {
  text-align: center;
  color: white;
  margin-top: 30px;
}

.countdown-message p {
  font-size: 24px;
  margin: 10px 0;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* ======================================
   Shooting Screen
   ====================================== */
#shooting-screen {
  background: #000;
}

.shooting-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: transparent;
  z-index: 10;
}

.progress-info {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  color: white;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(15px);
  padding: 25px 50px;
  border-radius: 30px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#shot-counter {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 10px;
  letter-spacing: 3px;
}

#next-shot-countdown {
  font-size: 72px;
  font-weight: bold;
  color: var(--primary);
  text-shadow: 0 0 30px var(--glow-color);
  animation: countPulse 1s ease-in-out infinite;
}

@keyframes countPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.progress-info p {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 8px;
}

/* Camera Switch Button */
.camera-switch-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 20px;
  cursor: pointer;
  pointer-events: auto;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.2s;
}

.camera-switch-btn:active {
  background: rgba(0, 0, 0, 0.7);
}

/* Manual Capture Button */
.manual-capture-btn {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  background: var(--btn-gradient);
  border: none;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.3),
    0 10px 40px var(--shadow-color);
  transition: all 0.3s ease;
  display: none;
}

.manual-capture-btn.visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

.manual-capture-btn::before {
  content: "";
  width: 80px;
  height: 80px;
  background: white;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.manual-capture-btn:hover {
  transform: translateX(-50%) scale(1.1);
}

.manual-capture-btn:active::before {
  transform: scale(0.85);
}

/* Flash Effect */
.flash-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  opacity: 0;
  pointer-events: none;
}

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

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

/* Filter Panel */
/* Filter panel in selection screen */
.filter-panel-selection {
  background: var(--card-bg);
  border-radius: 15px;
  border: 1px solid var(--primary-light, rgba(0,0,0,0.1));
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-panel-selection .filter-tabs {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  padding: 3px;
}

.filter-panel-selection .filter-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary, #666);
  font-size: 12px;
  font-family: inherit;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-panel-selection .filter-tab.active {
  background: var(--btn-gradient);
  color: white;
}

.filter-panel-selection .filter-preset-scroll {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  max-height: none;
  overflow-y: visible;
}

.filter-panel-selection .filter-btn {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.filter-panel-selection .filter-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: var(--primary);
}

.filter-panel-selection .filter-btn.active {
  background: var(--btn-gradient);
  border-color: var(--primary);
  color: white;
}

/* Filter Adjust Panel */
.filter-adjust-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0;
}

.adjust-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-panel-selection .adjust-row label {
  color: var(--text-primary);
  font-size: 11px;
  min-width: 28px;
  flex-shrink: 0;
}

.filter-panel-selection .adjust-row input[type="range"] {
  flex: 1;
  height: 20px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
  cursor: pointer;
  position: relative;
}

.filter-panel-selection .adjust-row input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.filter-panel-selection .adjust-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  margin-top: -6px;
}

.filter-panel-selection .adjust-val {
  color: var(--text-secondary, #666);
  font-size: 10px;
  min-width: 32px;
  text-align: right;
}

/* Camera Source Toggle */
.camera-source-toggle {
  display: flex;
  gap: 4px;
}

.cam-src-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.cam-src-btn.active {
  background: var(--btn-gradient);
  color: white;
  border-color: var(--primary);
}

/* Sticker Panel */
.sticker-panel {
  margin-top: 8px;
  background: rgba(var(--card-bg-rgb, 255,255,255), 0.05);
  border-radius: 12px;
  padding: 8px;
}

.sticker-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.sticker-tab {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: rgba(255, 255, 255, 0.5);
  padding: 6px;
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.sticker-tab.active {
  background: var(--primary);
  color: white;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.sticker-item {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.sticker-item:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.shape-preview-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  min-height: 48px;
}
.shape-preview-item canvas {
  display: block;
}

.sticker-text-add {
  grid-column: span 4;
  font-size: 13px;
  color: var(--primary);
}

.sticker-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.sticker-action-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.5);
  padding: 4px;
  border-radius: 6px;
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
}

.sticker-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

/* QR / Printer Popup */
.qr-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.qr-popup-content {
  background: #1a1a2e;
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  max-width: 460px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.qr-popup-content canvas#qr-canvas {
  max-width: 100%;
  height: auto;
}

.qr-popup-content h3 {
  color: white;
  margin: 0 0 16px;
  font-size: 18px;
}

.qr-popup-content canvas {
  border-radius: 12px;
  margin: 8px 0;
}

.qr-url {
  display: inline-block;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-family: monospace;
  word-break: break-all;
  margin: 8px 0;
  text-decoration: underline;
  cursor: pointer;
}

.qr-url:hover {
  color: #fff;
}

.qr-hint {
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  margin: 4px 0 16px;
}

.qr-popup-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

/* ─── 사진별 줌/팬 조절 패널 ─── */
.photo-adjust-panel {
  margin: 12px 0;
  padding: 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 12px;
}
.photo-adjust-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 8px;
}
.photo-adjust-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.photo-adjust-row {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.photo-adjust-badge {
  width: 24px; height: 24px;
  border-radius: 50%;
  color: #fff;
  text-align: center;
  line-height: 24px;
  font-weight: 700;
  font-size: 12px;
}
.photo-adjust-row input[type="range"] {
  width: 100%;
}
.photo-adjust-row .photo-adjust-val {
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary, #666);
}
.photo-adjust-row .photo-adjust-reset {
  padding: 4px 10px;
  font-size: 11px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.photo-adjust-panel.pan-mode {
  background: rgba(99, 102, 241, 0.08);
  outline: 2px dashed rgba(99, 102, 241, 0.45);
}

.secondary-btn.small {
  padding: 4px 10px;
  font-size: 11px;
}

/* 사진 위치 조정 모드: 스티커 입력 막고 사진 슬롯에 커서 표시 */
.preview-container.pan-mode #sticker-overlay-canvas {
  pointer-events: none;
}
.preview-container.pan-mode #preview-canvas {
  cursor: grab;
}
.preview-container.pan-mode.panning #preview-canvas {
  cursor: grabbing;
}

/* ─── 이모지 검색 + 카테고리 ─── */
.sticker-search-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 8px 0;
}
.sticker-search {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 18px;
  font-size: 13px;
  outline: none;
  background: #fff;
  transition: border-color 0.15s;
}
.sticker-search:focus {
  border-color: var(--primary, #FF5C8A);
}
.sticker-search-clear {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  color: #777;
}
.sticker-search-clear:hover { background: #f5f5f7; }
.emoji-category-header {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.55);
  letter-spacing: 0.4px;
  padding: 8px 4px 4px;
  margin-top: 4px;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}
.emoji-category-header:first-child {
  border-top: none;
  margin-top: 0;
}
.emoji-empty {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 12px;
  color: #999;
  padding: 16px;
}

.qr-popup-content select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 14px;
  font-family: inherit;
}

/* QR / Print Save Buttons */
.save-btn.qr-share {
  background: linear-gradient(135deg, #667eea, #764ba2);
}

.save-btn.print-save {
  background: linear-gradient(135deg, #2d3436, #636e72);
}

.save-btn.gif-save {
  background: linear-gradient(135deg, #e17055, #d63031);
}

/* ======================================
   Selection Screen
   ====================================== */
#selection-screen {
  background: var(--bg-gradient);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.selection-container {
  display: flex;
  width: 100%;
  height: 100%;
  padding: 30px;
  gap: 30px;
}

.threecut-layout {
  flex: 0 0 45%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 20px;
  background: var(--card-bg);
  border-radius: 30px;
  box-shadow: 0 20px 60px var(--shadow-color);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 20px;
  box-sizing: border-box;
}

.threecut-layout h2 {
  font-size: 22px;
  background: var(--btn-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
  letter-spacing: 3px;
  text-align: center;
}

/* Template Selection */
.template-selection {
  width: 100%;
  padding: 15px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 15px;
  border: 1px solid var(--primary-light);
  flex-shrink: 0;
}

.template-label {
  font-size: 13px;
  color: var(--text-primary);
  margin: 0 0 10px 0;
  font-weight: 600;
  text-align: center;
}

.template-grid {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 100%;
}

.template-item {
  min-width: 60px;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  position: relative;
  flex-shrink: 0;
  padding: 6px 6px 20px;
  gap: 2px;
}

.template-item canvas {
  max-width: 90px;
  max-height: 110px;
  border-radius: 4px;
}

.template-item .template-name {
  position: absolute;
  bottom: 3px;
  font-size: 12px;
  white-space: nowrap;
}

.template-item:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 15px var(--shadow-color);
}

.template-item.selected {
  border-color: var(--primary);
  transform: scale(1.08);
  box-shadow: 0 0 0 3px var(--glow-color), 0 4px 15px var(--shadow-color);
}

/* Custom Text Input */
.custom-text-input {
  width: 100%;
  padding: 15px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 15px;
  border: 1px solid var(--primary-light);
  flex-shrink: 0;
}

.custom-text-input label {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  margin: 0 0 10px 0;
  font-weight: 600;
  text-align: center;
}

.custom-text-input textarea {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid var(--primary-light);
  border-radius: 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: all 0.3s ease;
  resize: vertical;
  min-height: 60px;
  max-height: 90px;
  line-height: 1.5;
  box-sizing: border-box;
}

.custom-text-input textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--shadow-color);
}

.text-style-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
  margin-top: 10px;
  flex-wrap: nowrap;
}

.text-size-control,
.text-color-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.text-size-control label,
.text-color-control label {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.text-size-control input[type="range"] {
  flex: 1;
  min-width: 60px;
}

.text-size-control span {
  font-size: 12px;
  color: var(--text-primary);
  min-width: 40px;
  text-align: right;
  flex-shrink: 0;
}

.text-color-control select {
  flex: 1;
  min-width: 100px;
  padding: 6px 10px;
  border: 2px solid var(--primary-light);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.3s ease;
}

.text-color-control select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--shadow-color);
}

.preview-container {
  position: relative;
  width: 100%;
  border-radius: 15px;
  overflow: visible;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px;
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid var(--primary-light);
  min-height: 300px;
  flex-shrink: 0;
}

#preview-canvas {
  max-width: 100%;
  width: auto !important;
  height: auto !important;
  display: block;
  border-radius: 12px;
  box-shadow: 0 10px 30px var(--shadow-color);
  object-fit: contain;
  aspect-ratio: auto;
}

.selection-info {
  margin-top: 0;
  text-align: center;
  width: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--primary-light);
  flex-shrink: 0;
}

#selection-count {
  font-size: 20px;
  color: var(--primary);
  font-weight: bold;
  margin-bottom: 15px;
}

.preview-controls {
  margin-bottom: 15px;
}

.preview-controls button {
  padding: 10px 20px;
  font-size: 14px;
}

.result-controls {
  margin: 15px 0;
  display: flex;
  justify-content: center;
}

.save-info-box {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.save-info-box p {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.save-info-box p + p {
  margin-top: 6px;
}

.photo-gallery {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border-radius: 30px;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
}

.photo-gallery h3 {
  font-size: 22px;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 20px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.photo-item {
  position: relative;
  aspect-ratio: 4/3;
  border-radius: 15px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shot-number-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  pointer-events: none;
}

.photo-item:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 30px var(--shadow-color);
}

.photo-item.selected {
  outline: 4px solid var(--primary);
  outline-offset: 2px;
  transform: scale(1.02);
}

.selection-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  background: var(--btn-gradient);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  animation: badgePop 0.3s ease-out;
  z-index: 2;
}

@keyframes badgePop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.gallery-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px solid rgba(0, 0, 0, 0.05);
}

/* ======================================
   Result Screen
   ====================================== */
#result-screen {
  background: var(--bg-gradient);
  align-items: center;
  justify-content: center;
}

.result-container {
  text-align: center;
  padding: 40px;
  background: var(--card-bg);
  border-radius: 40px;
  box-shadow: 0 30px 80px var(--shadow-color);
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  animation: resultPop 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes resultPop {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(50px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.result-container h2 {
  font-size: 48px;
  background: var(--btn-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 25px;
  animation: celebrateText 1s ease-out;
}

@keyframes celebrateText {
  0%,
  100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.1) rotate(-2deg);
  }
  50% {
    transform: scale(1.1) rotate(2deg);
  }
  75% {
    transform: scale(1.05);
  }
}

.final-threecut {
  max-height: 45vh;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 15px 40px var(--shadow-color);
}

#final-canvas {
  max-width: 100%;
  max-height: 45vh;
  display: block;
}

/* Result Content Layout */
.result-content {
  display: flex;
  gap: 30px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 25px;
}

.result-photo-section,
.result-video-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.03);
  padding: 20px;
  border-radius: 20px;
}

.result-photo-section .final-threecut {
  margin-bottom: 15px;
}

.video-preview {
  margin-bottom: 15px;
}

.video-preview video {
  max-width: 280px;
  max-height: 350px;
  width: 100%;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 8px 25px var(--shadow-color);
}

/* Save Buttons */
.save-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.save-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  border: none;
  border-radius: 30px;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px var(--shadow-color);
}

.save-btn .save-icon {
  font-size: 20px;
}

.save-btn.photo-save {
  background: var(--btn-gradient);
  color: white;
}

.save-btn.video-save {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow-color);
}

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

.save-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.save-message {
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
  min-height: 20px;
}

.result-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
}

/* ======================================
   Loading Overlay
   ====================================== */
.overlay-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient);
  backdrop-filter: blur(20px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.overlay-screen.active {
  display: flex;
  animation: overlayFade 0.3s ease-out;
}

@keyframes overlayFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.loading-content {
  text-align: center;
}

.spinner {
  width: 80px;
  height: 80px;
  border: 6px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 30px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#loading-message {
  font-size: 24px;
  color: var(--primary);
  font-weight: bold;
  animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ======================================
   Theme Specific Decorations
   ====================================== */

/* Neon Cyber Theme */
[data-theme="neon-cyber"] .overlay {
  border: 1px solid rgba(0, 255, 255, 0.3);
  box-shadow: 0 0 50px rgba(0, 255, 255, 0.2),
    inset 0 0 50px rgba(0, 255, 255, 0.05);
}

[data-theme="neon-cyber"] .theme-card.selected {
  box-shadow: 0 0 30px var(--glow-color), 0 0 60px var(--primary-dark);
}

/* Graduation Gold Theme */
[data-theme="graduation-gold"] .overlay h1 {
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

/* Korean Traditional Theme */
[data-theme="korean-traditional"] .overlay {
  border: 3px double var(--primary);
}

/* ======================================
   Scrollbar Styling
   ====================================== */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--primary-light);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* ======================================
   Template Editor & Theme Editor
   ====================================== */

#template-editor-screen,
#theme-editor-screen {
  background: var(--bg-gradient);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.template-editor-container {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 40px var(--shadow-color);
}

.template-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--primary-light);
}

.template-editor-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 28px;
  font-weight: 700;
}

.template-editor-content {
  min-height: 400px;
}

.editor-step {
  animation: fadeIn 0.3s ease;
}

.editor-step h3 {
  margin: 0 0 25px 0;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--primary-light);
}

.editor-form-group {
  margin-bottom: 25px;
}

.editor-form-group label {
  display: block;
  margin-bottom: 10px;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 15px;
}

.editor-form-group input[type="text"],
.editor-form-group input[type="number"],
.editor-form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--primary-light);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  background: white;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.editor-form-group input[type="text"]:focus,
.editor-form-group input[type="number"]:focus,
.editor-form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 92, 138, 0.15);
  transform: translateY(-1px);
}

.editor-form-group input[type="color"] {
  width: 80px;
  height: 45px;
  border: 2px solid var(--primary-light);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.editor-form-group input[type="color"]:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#template-emoji-input,
#theme-emoji-input {
  font-size: 28px;
  text-align: center;
  width: 100px !important;
  padding: 12px !important;
}

#custom-size-inputs {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

#custom-size-inputs input {
  flex: 1;
}

#background-image-preview,
#theme-background-image-preview {
  margin-top: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#background-image-preview img,
#theme-background-image-preview img {
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#decoration-images-list,
#theme-decoration-images-list {
  margin-top: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

#decoration-images-list > div,
#theme-decoration-images-list > div {
  position: relative;
  border: 2px solid var(--primary-light);
  border-radius: 10px;
  padding: 8px;
  background: white;
  transition: all 0.3s ease;
}

#decoration-images-list > div:hover,
#theme-decoration-images-list > div:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#decoration-images-list img,
#theme-decoration-images-list img {
  display: block;
  border-radius: 6px;
}

#template-preview-canvas,
#theme-preview-canvas {
  background: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
}

.editor-step .primary-btn,
.editor-step .secondary-btn {
  min-width: 120px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 10px;
  transition: all 0.3s ease;
}

.editor-step .primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 92, 138, 0.4);
}

.editor-step .secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 색상 선택 영역 개선 */
.editor-form-group > div[style*="display: flex"] {
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-form-group span[id*="color-value"] {
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 6px 12px;
  background: var(--primary-light);
  border-radius: 6px;
  min-width: 90px;
  text-align: center;
}

/* 그라데이션 색상 선택 영역 */
.editor-form-group > div[style*="flex-wrap: wrap"] > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.editor-form-group > div[style*="flex-wrap: wrap"] label {
  font-size: 12px;
  font-weight: 500;
  margin: 0;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  #template-editor-screen,
  #theme-editor-screen {
    padding: 10px;
  }

  .template-editor-container {
    padding: 20px;
    margin: 0;
    border-radius: 15px;
  }

  .template-editor-header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  .template-editor-header h2 {
    font-size: 22px;
  }

  .editor-step h3 {
    font-size: 18px;
  }

  #custom-size-inputs {
    flex-direction: column;
  }

  .editor-form-group input[type="color"] {
    width: 70px;
    height: 40px;
  }

  #template-emoji-input,
  #theme-emoji-input {
    width: 80px !important;
  }
}

/* ======================================
   Responsive Design
   ====================================== */
@media (max-width: 1200px) {
  .selection-container {
    flex-direction: column;
  }

  .threecut-layout {
    flex: none;
  }

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

@media (max-width: 900px) {
  .theme-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .overlay {
    padding: 30px 25px;
    max-width: 95%;
  }

  .overlay h1 {
    font-size: 36px;
    letter-spacing: 3px;
  }

  .overlay .subtitle {
    font-size: 14px;
  }

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

  .theme-card .theme-preview {
    font-size: 28px;
  }

  .theme-card .theme-name {
    font-size: 11px;
    padding: 8px;
  }

  #countdown-number {
    font-size: 100px;
  }

  .settings-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .setting-group {
    justify-content: center;
    padding: 12px 18px;
  }

  .selection-container {
    flex-direction: column;
    padding: 10px;
    gap: 15px;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  /* 모바일: 사진 갤러리를 먼저 보여주기 */
  .photo-gallery {
    order: 1;
    flex: none;
    width: 100%;
    padding: 15px;
    max-height: none;
    overflow: visible;
  }

  .photo-gallery h3 {
    font-size: 16px;
    margin-bottom: 15px;
  }

  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    overflow: visible;
  }

  .gallery-actions {
    margin-top: 15px;
    padding: 10px 0;
  }

  /* 모바일: 템플릿 선택/미리보기를 하단에 배치 */
  .threecut-layout {
    order: 2;
    flex: none;
    padding: 15px;
    height: auto;
    max-height: none;
    overflow: visible;
    gap: 12px;
  }

  .threecut-layout h2 {
    font-size: 18px;
    margin: 0;
  }

  .template-selection {
    padding: 10px;
  }

  .template-label {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .template-grid {
    gap: 6px;
  }

  .template-item {
    width: 45px;
    height: 60px;
  }

  .template-item canvas {
    width: 40px;
    height: 50px;
  }

  .preview-container {
    min-height: 200px;
    padding: 10px;
  }

  #preview-canvas {
    max-width: 100%;
    max-height: 400px; /* 세로 템플릿을 위해 높이 증가 */
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    aspect-ratio: auto; /* 원본 비율 유지 */
  }

  .custom-text-input {
    padding: 10px;
  }

  .custom-text-input label {
    font-size: 11px;
    margin-bottom: 6px;
  }

  .custom-text-input textarea {
    padding: 8px 10px;
    font-size: 11px;
    min-height: 45px;
    max-height: 70px;
  }

  .text-style-controls {
    margin-top: 8px;
    gap: 8px;
    flex-direction: row;
    flex-wrap: nowrap;
  }

  .text-size-control,
  .text-color-control {
    font-size: 10px;
    flex: 1;
    min-width: 0;
  }

  .text-size-control label,
  .text-color-control label {
    font-size: 10px;
    white-space: nowrap;
  }

  .text-size-control input[type="range"] {
    width: auto;
    flex: 1;
    min-width: 50px;
  }

  .text-size-control span {
    font-size: 9px;
    min-width: 35px;
  }

  .text-color-control select {
    padding: 4px 6px;
    font-size: 10px;
    flex: 1;
    min-width: 80px;
  }

  .selection-info {
    margin-top: 0;
    padding-top: 8px;
  }

  .selection-info button {
    width: 100%;
    margin-top: 8px;
  }

  .result-content {
    flex-direction: column;
    gap: 20px;
  }

  .result-photo-section,
  .result-video-section {
    width: 100%;
    padding: 15px;
  }

  .video-preview {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .video-preview video {
    max-width: 100%;
    max-height: 50vh;
    width: 100%;
    height: auto;
  }

  .result-container {
    padding: 20px 15px;
    max-height: 100vh;
    overflow-y: auto;
  }

  .result-container h2 {
    font-size: 28px;
    margin-bottom: 15px;
  }

  .countdown-message p {
    font-size: 16px;
    margin: 6px 0;
  }

  .progress-info {
    padding: 15px 25px;
    top: 20px;
  }

  #shot-counter {
    font-size: 20px;
    margin-bottom: 6px;
  }

  /* Touch targets minimum 44px */
  button, a, select, input {
    min-height: 44px;
  }

  .save-actions {
    flex-direction: column;
    gap: 10px;
  }

  .save-btn {
    width: 100%;
  }

  .template-grid {
    gap: 8px;
  }

  .template-item {
    width: 50px;
    height: 68px;
  }

  .template-item canvas {
    width: 45px;
    height: 55px;
  }

}

@media (max-width: 480px) {
  .overlay {
    padding: 15px 10px;
  }

  .overlay h1 {
    font-size: 24px;
    letter-spacing: 2px;
  }

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

  .theme-card {
    border-width: 2px;
  }

  .settings-row {
    gap: 8px;
  }

  .setting-group {
    padding: 10px 12px;
    font-size: 12px;
    gap: 8px;
  }

  .setting-group label {
    font-size: 12px;
  }

  .primary-btn {
    padding: 14px 28px;
    font-size: 15px;
    width: 100%;
  }

  .secondary-btn {
    padding: 12px 24px;
    font-size: 14px;
  }

  #countdown-number {
    font-size: 80px;
  }

  .countdown-message p {
    font-size: 14px;
  }

  .progress-info {
    padding: 12px 20px;
    top: 10px;
  }

  #shot-counter {
    font-size: 18px;
  }

  .result-container h2 {
    font-size: 24px;
  }
}

/* ======================================
   Standard Dawith Footer
   ====================================== */
.dawith-footer {
  position: relative;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  padding: 2rem 0;
  width: 100%;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .footer-content {
    flex-direction: row;
  }
}

.footer-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  text-align: center;
}

@media (min-width: 768px) {
  .footer-info {
    text-align: left;
  }
}

.footer-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.7);
}

.footer-subtitle {
  font-size: 0.75rem;
  color: rgba(0, 0, 0, 0.5);
}

.dawith-ai-button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: white;
  padding: 0.5rem 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  text-decoration: none;
  cursor: pointer;
}

.dawith-ai-button:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transform: scale(1.02);
}

.dawith-ai-logo {
  width: 2.25rem;
  height: 2.25rem;
  object-fit: cover;
  border-radius: 50%;
}

.button-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.created-by {
  font-size: 9px;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
  margin-bottom: 0.125rem;
}

.dawith-ai-text {
  font-size: 0.875rem;
  font-weight: 700;
  color: #0f172a;
}

/* ======================================
   필터 패널 및 조절 탭 스타일
   ====================================== */
.filter-panel-selection {
  width: 100%;
  padding: 15px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 15px;
  border: 1px solid var(--primary-light);
  margin-bottom: 10px;
}

.filter-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 8px;
}

.filter-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.filter-tab.active {
  color: var(--primary);
}

.filter-tab.active::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--primary);
  border-radius: 3px;
}

.filter-preset-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: thin;
}

.filter-adjust-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 5px 0;
}

.adjust-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.adjust-row label {
  font-size: 13px;
  width: 40px;
  color: #555;
  margin: 0 !important;
  text-align: left !important;
}

.adjust-row input[type="range"] {
  flex: 1;
  height: 20px;
  cursor: pointer;
}

.adjust-val {
  font-size: 12px;
  width: 45px;
  text-align: right;
  color: var(--primary);
  font-weight: 600;
}

#ad-wrapper-sidebar {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
}

@media (max-width: 768px) {
  #ad-wrapper-sidebar {
    display: none;
  }
}

/* 배너 광고 - 모든 화면에서 표시 */
#ad-wrapper-banner {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  min-height: 50px;
}

