:root {
  --primary-color: #4a6fa5;
  --secondary-color: #6b8cbc;
  --accent-color: #ff7b54;
  --light-bg: #f1f2f3;
  --card-bg: #ffffff;
  --text-dark: #333333;
  --text-light: #666666;
  --border-radius: 10px;
  --box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--light-bg);
}

.container{
  box-sizing: border-box;
  max-width: 1560px;
  min-width: 1240px;
  width: 100%;
  margin: 20px auto;
  color: var(--text-dark);
}

.container *{
  box-sizing: border-box;
}

header {
  text-align: center;
  margin-bottom: 25px;
}

header h1 {
  font-size: 2.2rem;
  margin-bottom: 5px;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-light);
  max-width: 95%;
  margin: 0 auto;
}

.main-content {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.control-panel {
  flex: 0 0 320px;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--box-shadow);
  height: fit-content;
}

.control-group {
  margin-bottom: 25px;
}

.control-group h3 {
  margin-bottom: 15px;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
}

.input-group {
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-dark);
}

input[type="number"], select {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

input[type="number"]:focus, select:focus {
  border-color: var(--primary-color);
  outline: none;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 25px;
}

button {
  padding: 14px 20px;
  border: none;
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-generate {
  background-color: var(--primary-color);
  color: white;
}

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

.btn-download {
  background-color: var(--accent-color);
  color: white;
}

.btn-download:hover {
  background-color: #ff9b7b;
  transform: translateY(-2px);
}

.btn-clear {
  background-color: #f1f2f3;
  color: var(--text-dark);
  border: 1px solid #ddd;
}

.btn-clear:hover {
  background-color: #e5e5e5;
  transform: translateY(-2px);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.maze-container {
  flex: 1;
  width: calc(100% - 340px);
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--box-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 600px;
  position: relative;
}

.canvas-wrapper {
  width: 100%;
  overflow: auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
  padding: 20px;
}

#mazeCanvas {
  display: block;
  background: white;
  border: 1px solid #eee;
  margin: auto;
  max-width: 100%;
}

.info-section {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--box-shadow);
  margin-bottom: 20px;
}

.info-section h2 {
  margin-bottom: 20px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.info-content {
  display: flex;
  gap: 20px;
}

.info-box {
  flex: 1;
}

.info-box h3 {
  margin-bottom: 15px;
  color: var(--secondary-color);
  font-size: 1.2rem;
}

.info-box p {
  margin-top: 10px;
  color: var(--text-light);
}

.algorithm-steps {
  background: #f8f9fa;
  border-left: 4px solid var(--primary-color);
  padding: 20px;
  border-radius: 0 8px 8px 0;
  margin-top: 20px;
}

.step {
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
}

.step-number {
  background: var(--primary-color);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: bold;
}

.mobile-tip {
  background: #e8f4ff;
  border-radius: var(--border-radius);
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

footer {
  text-align: center;
  padding: 10px;
  color: var(--text-light);
  font-size: 0.9rem;
}

.stats {
  display: flex;
  flex-direction: column;
  justify-content: space-around;

}

.stat-item {
  display: flex;
  text-align: center;
  background: #f8f9fa;
  border-radius: var(--border-radius);
  padding: 15px;
  margin-top: 20px;
  font-size: 1rem;
}
.stat-value {
  font-weight: bold;
  color: var(--primary-color);
}

.stat-label {
  color: var(--text-light);
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(74, 111, 165, 0.2);
  border-radius: 50%;
  border-top: 5px solid var(--primary-color);
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

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

.loading-text {
  font-size: 1.2rem;
  color: var(--primary-color);
  font-weight: 600;
}

.size-warning {
  background: #fff9db;
  border-left: 4px solid #ffd43b;
  padding: 10px 15px;
  margin-top: 15px;
  border-radius: 4px;
  font-size: 0.9rem;
}
