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

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f5f5;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

/* Header */
.header {
  height: 50px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 30px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.controls {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 8px 16px;
  background: #1976d2;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.3s ease;
}

.btn:hover:not(:disabled) {
  background: #1565c0;
}

.btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.step-info {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: #333;
  white-space: nowrap;
  margin-left: auto;
}

/* Main Content */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #f5f5f5;
}

.groups-container {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  height: 100%;
  flex-wrap: wrap;
  align-content: center;
}

/* Group Box */
.group {
  background: white;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  max-height: 85vh;
}

.group-header {
  border-bottom: 2px solid #ddd;
  padding-bottom: 10px;
  font-weight: 600;
}

.group-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.group-info {
  font-size: 12px;
  color: #666;
  line-height: 1.4;
}

/* Group Colors */
.group.blue {
  border-left: 4px solid #1976d2;
}

.group.blue .group-title {
  color: #1976d2;
}

.group.red {
  border-left: 4px solid #d32f2f;
}

.group.red .group-title {
  color: #d32f2f;
}

.group.orange {
  border-left: 4px solid #f57c00;
}

.group.orange .group-title {
  color: #f57c00;
}

/* Names Container */
.names-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  flex: 1;
}

.name {
  padding: 8px 12px;
  background: #f5f5f5;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.3s ease;
}

.name.moving {
  border: 3px solid #ffc107;
  box-shadow: 0 0 12px rgba(255, 193, 7, 0.8), inset 0 0 8px rgba(255, 193, 7, 0.5);
  animation: nameGlow 2s ease-in-out forwards;
}

@keyframes nameGlow {
  0% {
    border: 3px solid #ffc107;
    box-shadow: 0 0 12px rgba(255, 193, 7, 0.8), inset 0 0 8px rgba(255, 193, 7, 0.5);
    opacity: 1;
  }
  100% {
    border: 3px solid #ffc107;
    box-shadow: 0 0 12px rgba(255, 193, 7, 0.8), inset 0 0 8px rgba(255, 193, 7, 0.5);
    opacity: 1;
  }
}

/* Responsive adjustments */
@media (max-width: 1400px) {
  .groups-container {
    gap: 15px;
  }
  
  .group {
    padding: 12px;
  }
  
  .names-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    height: auto;
    padding: 10px;
    gap: 10px;
  }
  
  .controls {
    width: 100%;
    justify-content: center;
  }
  
  .step-info {
    margin-left: 0;
    justify-content: center;
    width: 100%;
  }
  
  .groups-container {
    flex-direction: column;
    gap: 15px;
  }
  
  .group {
    width: 90vw;
    max-height: 40vh;
  }
  
  .names-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Loading Modal */
.loading-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.loading-modal.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  max-width: 400px;
}

.modal-content.success {
  background: #f0f9ff;
  border: 2px solid #4caf50;
}

.modal-content.success .spinner {
  display: none;
}

.modal-content.success::before {
  content: "✅";
  font-size: 48px;
  display: block;
  margin-bottom: 15px;
  animation: successPulse 0.6s ease;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #1976d2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes successPulse {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

#modalMessage {
  font-size: 16px;
  color: #333;
  margin: 0;
  line-height: 1.5;
}

.modal-content.success #modalMessage {
  color: #1976d2;
  font-weight: 500;
}
