:root {
  --primary-color: #3498db;
  --success-color: #2ecc71;
  --danger-color: #e74c3c;
  --warning-color: #f39c12;
  --light-color: #f5f5f5;
  --dark-color: #2c3e50;
  --background-color: #ecf0f1;
  --card-background: #ffffff;
  --text-color: #2c3e50;
  --border-radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  --transition-speed: 0.3s;
  --gradient-primary: linear-gradient(135deg, #3498db, #2980b9);
  --gradient-success: linear-gradient(135deg, #2ecc71, #27ae60);
  --gradient-danger: linear-gradient(135deg, #e74c3c, #c0392b);
  --gradient-warning: linear-gradient(135deg, #f39c12, #d35400);
  
  /* New variables */
  --card-shadow: 0 15px 35px rgba(50, 50, 93, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
  --card-shadow-hover: 0 20px 40px rgba(50, 50, 93, 0.15), 0 10px 20px rgba(0, 0, 0, 0.1);
  --card-border-radius: 20px;
  --button-border-radius: 12px;
}

/* Enhanced Card Component */
.swipe-container {
  position: relative;
  flex: 3;
  min-height: 70vh;
  perspective: 1200px;
  border-radius: var(--card-border-radius);
  background: var(--card-background);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: box-shadow 0.4s ease, transform 0.4s ease;
}

.swipe-container:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-5px);
}

.image-card {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--card-border-radius);
  overflow: hidden;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease-out;
  transform-origin: center center;
  background-color: var(--card-background);
  touch-action: none;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: var(--card-shadow);
}

.image-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent 70%, rgba(0,0,0,0.2));
  pointer-events: none;
  z-index: 1;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.image-card:hover::before {
  opacity: 0.5;
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.5s ease;
  pointer-events: none;
}

.image-card:hover img {
  transform: scale(1.02);
}

/* Enhanced Swipe Directions */
.swipe-directions {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}

.swipe-container:hover .swipe-directions {
  opacity: 0.3;
}

.direction-arrow {
  position: absolute;
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: white;
  border-radius: 50%;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.arrow-left {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--gradient-danger);
}

.arrow-right {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--gradient-success);
}

.arrow-up {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gradient-primary);
}

.arrow-down {
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gradient-warning);
}

/* Enhanced Action Hints */
.action-hint {
  position: absolute;
  background-color: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 12px 20px;
  border-radius: 30px;
  font-weight: bold;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 10;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: scale(0.9);
  border-left: 4px solid;
}

.action-hint.visible {
  opacity: 1;
  transform: scale(1);
}

.left-hint { 
  left: 20px; 
  top: 50%; 
  transform: translateY(-50%); 
  border-color: var(--danger-color);
}

.right-hint { 
  right: 20px; 
  top: 50%; 
  transform: translateY(-50%); 
  border-color: var(--success-color);
}

.up-hint { 
  top: 20px; 
  left: 50%; 
  transform: translateX(-50%); 
  border-color: var(--primary-color);
}

.down-hint { 
  bottom: 20px; 
  left: 50%; 
  transform: translateX(-50%); 
  border-color: var(--warning-color);
}

/* Enhanced Swipe Animations */
.image-card.swipe-left {
  transform: translateX(-150%) rotate(-30deg);
  opacity: 0;
}

.image-card.swipe-right {
  transform: translateX(150%) rotate(30deg);
  opacity: 0;
}

.image-card.swipe-up {
  transform: translateY(-150%) rotate(10deg);
  opacity: 0;
}

.image-card.swipe-down {
  transform: translateY(150%) rotate(-10deg);
  opacity: 0;
}

/* Enhanced Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.3s ease;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border: none;
  border-radius: var(--button-border-radius);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  font-size: 1rem;
  color: white;
  position: relative;
  overflow: hidden;
  z-index: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.action-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: -1;
}

.action-btn:hover::before {
  transform: translateX(0);
}

.action-btn:hover {
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.action-btn:active {
  transform: translateY(-2px) scale(0.98);
}

#btn-left { 
  background: var(--gradient-danger);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

#btn-right { 
  background: var(--gradient-success);
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

#btn-up { 
  background: var(--gradient-primary);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

#btn-down { 
  background: var(--gradient-warning);
  box-shadow: 0 4px 12px rgba(243, 156, 18, 0.3);
}

/* Enhanced Side Panel */
.side-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 20px;
  min-width: 320px;
}

.filter-controls, .action-buttons, .status-area {
  background-color: var(--card-background);
  padding: 24px;
  border-radius: var(--card-border-radius);
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.filter-controls:hover, .action-buttons:hover, .status-area:hover {
  transform: translateY(-5px);
  box-shadow: var(--card-shadow-hover);
}

/* Enhanced Filter Buttons */
.filter-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--button-border-radius);
  background-color: var(--light-color);
  color: var(--dark-color);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  position: relative;
  overflow: hidden;
}

.filter-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.filter-btn.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

/* Enhanced Header */
.header {
  text-align: center;
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  position: relative;
}

.app-title {
  font-size: 2.4rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 15px;
  color: var(--dark-color);
  letter-spacing: -0.5px;
  transition: transform 0.3s ease;
}

.app-title:hover {
  transform: scale(1.03);
}

.app-title i {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.history-link {
  padding: 12px 22px;
  background: var(--gradient-primary);
  color: white;
  text-decoration: none;
  border-radius: var(--button-border-radius);
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-link:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(52, 152, 219, 0.4);
}

/* Enhanced Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  overflow: auto;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.modal.show {
  opacity: 1;
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 1200px;
  padding: 30px;
  transform: scale(0.95);
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1001;
}

.modal.show .modal-content {
  transform: scale(1);
  opacity: 1;
}

#fullscreen-image {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--card-border-radius);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease;
}

#fullscreen-image:hover {
  transform: scale(1.02);
}

.close-modal {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.5);
  transition: all 0.3s;
}

.close-modal:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: rotate(90deg);
}

.modal-info {
  margin-top: 20px;
  color: white;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 20px 30px;
  border-radius: var(--card-border-radius);
  text-align: center;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 20px;
  backdrop-filter: blur(5px);
}

/* Enhanced Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background-color: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 16px 30px;
  border-radius: 50px;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 2000;
  pointer-events: none;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  font-weight: 500;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Enhanced Progress Bar */
.progress-container {
  height: 6px;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 2000;
  background-color: rgba(255,255,255,0.2);
}

.progress-bar {
  height: 100%;
  background: var(--gradient-primary);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 0 3px 3px 0;
  box-shadow: 0 1px 5px rgba(52, 152, 219, 0.5);
}

/* Enhanced History Page */
.stats-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 30px;
  background-color: var(--card-background);
  padding: 30px;
  border-radius: var(--card-border-radius);
  box-shadow: var(--card-shadow);
  justify-content: space-between;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  border-radius: var(--card-border-radius);
  background-color: var(--light-color);
  min-width: 120px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stat-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.1);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: bold;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
}

.selection-item {
  background-color: var(--card-background);
  border-radius: var(--card-border-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  position: relative;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 4px solid transparent;
}

.selection-item:hover {
  transform: translateY(-10px);
  box-shadow: var(--card-shadow-hover);
}

.selection-item.selected {
  border-width: 12px;
  /* keep existing border-color set by action */
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-8px) scale(1.02);
}

.selection-action {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 8px 15px;
  border-radius: 20px;
  color: white;
  font-weight: bold;
  font-size: 0.9rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
}

.selection-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: space-around;
  padding: 12px 0;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  transform: translateY(10px);
  backdrop-filter: blur(4px);
}

.selection-item:hover .selection-controls {
  opacity: 1;
  transform: translateY(0);
}

.control-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s;
}

.control-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-3px);
}

/* Mobile Enhancements */
@media (max-width: 992px) {
  .container {
    padding: 15px;
  }
  
  .main-section {
    flex-direction: column;
  }
  
  .side-panel {
    position: static;
    width: 100%;
  }
  
  .action-buttons {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--card-background);
    padding: 15px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 1500;
    flex-direction: row;
    border-radius: 0;
    gap: 10px;
    justify-content: space-around;
  }
  
  .action-buttons:hover {
    transform: none;
  }
  
  .swipe-container {
    min-height: 60vh;
    margin-bottom: 90px;
  }
  
  .action-btn {
    padding: 15px;
    border-radius: 50%;
    width: 60px;
    height: 60px;
  }
  
  .action-btn .label {
    display: none;
  }
  
  .action-btn i {
    font-size: 1.5rem;
  }
  
  .app-title {
    font-size: 2rem;
  }
  
  .history-link {
    padding: 10px 16px;
  }
  
  /* Enhanced swipe indicators for mobile */
  .direction-arrow {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
  
  .action-hint {
    padding: 8px 16px;
    font-size: 0.9rem;
  }
}

/* Animation for card appearance */
@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.image-card {
  animation: cardAppear 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Improved loading indicator */
.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(52, 152, 219, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Swipe decision indicator */
.swipe-decision {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 5rem;
  color: white;
  z-index: 10;
  opacity: 0;
  transition: all 0.3s ease;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.swipe-decision.visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.decision-left { color: var(--danger-color); }
.decision-right { color: var(--success-color); }
.decision-up { color: var(--primary-color); }
.decision-down { color: var(--warning-color); }
