:root {
  --primary-dark: #2d1b1b;
  --primary: #4a2f2f;
  --primary-light: #6d4c4c;
  --secondary: #8d6e63;
  --accent-light: #d7ccc8;
  --accent: #baa69e;
  --background: #f4ece8;
  --text-dark: #2d1b1b;
  --text-light: #fff;
  --success: #4caf50;
  --error: #f44336;
  --soft-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --medium-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  --large-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  transition: all 0.3s ease;
}

body {
  font-family: "Vazirmatn", sans-serif;
  background: linear-gradient(135deg, var(--background) 0%, #f9e6dc 100%);
  color: var(--text-dark);
  direction: rtl;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.container {
  max-width: 900px;
  width: 100%;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  box-shadow: var(--large-shadow);
  padding: 2rem;
  backdrop-filter: blur(10px);
}

h1,
h2,
h3 {
  color: var(--primary-dark);
  text-align: center;
  margin-bottom: 1rem;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

h1 {
  font-size: 2.5rem;
  background: linear-gradient(to right, var(--primary-dark), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 2rem;
}

.puzzle-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  box-shadow: var(--medium-shadow);
  padding: 2rem;
  margin: 1rem 0;
}

.puzzle-description {
  background: linear-gradient(to right, var(--accent-light), var(--accent));
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.puzzle-description::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transform: skew(-15deg) translateX(-100%);
  transition: transform 0.5s;
}

.puzzle-description:hover::before {
  transform: skew(-15deg) translateX(100%);
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 15px;
  margin: 1.5rem 0;
}

.grid-item {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  border: 2px solid var(--primary);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--soft-shadow);
  transform: scale(1);
  font-weight: 600;
}

.grid-item:hover {
  transform: scale(1.05);
  box-shadow: var(--medium-shadow);
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  color: var(--text-light);
}

.grid-item.selected {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: var(--text-light);
  transform: scale(1.1);
  box-shadow: var(--medium-shadow);
}

.assignment {
  background: rgba(215, 204, 200, 0.5);
  border: 2px solid var(--secondary);
}

.constraints {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin: 1.5rem 0;
}

.constraint {
  background: linear-gradient(to right, var(--accent-light), var(--accent));
  border-radius: 10px;
  padding: 1rem;
  border-right: 6px solid var(--primary);
  transition: all 0.3s ease;
}

.constraint.satisfied {
  border-right-color: var(--success);
  background: linear-gradient(to right, #c8e6c9, #a5d6a7);
}

.constraint.violated {
  border-right-color: var(--error);
  background: linear-gradient(to right, #ffcdd2, #ef9a9a);
}

.buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 1.5rem 0;
}

button {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--text-light);
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  font-weight: 600;
  box-shadow: var(--soft-shadow);
  transform: scale(1);
}

button:hover {
  transform: scale(1.05);
  box-shadow: var(--medium-shadow);
}

.solve-btn {
  background: linear-gradient(135deg, var(--success), #2e7d32);
}

.solution-feedback {
  text-align: center;
  font-weight: bold;
  height: 30px;
  margin: 1rem 0;
  border-radius: 8px;
  padding: 0.5rem;
}

.solution-feedback.success {
  background: linear-gradient(to right, #c8e6c9, #a5d6a7);
  color: var(--success);
}

.solution-feedback.error {
  background: linear-gradient(to right, #ffcdd2, #ef9a9a);
  color: var(--error);
}

.hint-container {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--soft-shadow);
  border-right: 6px solid var(--secondary);
}

@media (max-width: 768px) {
  .grid-container {
    grid-template-columns: repeat(3, 1fr);
  }

  .container {
    padding: 1rem;
  }

  .buttons {
    flex-direction: column;
    align-items: center;
  }

  button {
    width: 100%;
  }
}
.home-button {
  position: absolute;
  top: 20px;
  left: 20px;
  display: inline-block;
  padding: 15px 30px;
  background: linear-gradient(135deg, #722afe, #2b86c5);
  color: white;
  font-size: 24px;
  text-decoration: none;
  border-radius: 50px;
  font-weight: bold;
  text-align: center;
  overflow: hidden;
  z-index: 1;
  box-shadow: 0 5px 15px rgba(43, 134, 197, 0.4);
  transition: all 0.3s ease;
}

.home-button:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #2b86c5, #722afe);
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
  border-radius: 50px;
}

.home-button:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(114, 42, 254, 0.6);
}

.home-button:hover:before {
  opacity: 1;
}

.home-button:active {
  transform: translateY(0);
  box-shadow: 0 5px 15px rgba(43, 134, 197, 0.4);
}

.home-button .icon {
  display: inline-block;
  margin-right: 10px;
  transition: transform 0.3s ease;
}

.home-button:hover .icon {
  transform: rotate(10deg);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(114, 42, 254, 0.7);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(114, 42, 254, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(114, 42, 254, 0);
  }
}

.home-button:hover {
  animation: pulse 1.5s infinite;
}

/* Enhanced mobile responsiveness */
@media only screen and (max-width: 768px) {
  body {
    padding: 1rem 0.5rem;
    padding-top: 70px; /* Add space for the fixed home button */
  }

  .container {
    padding: 1rem;
    border-radius: 15px;
  }

  h1 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
  }

  .puzzle-container {
    padding: 1rem;
  }

  .puzzle-description {
    padding: 1rem;
  }

  /* Already included in original CSS, but enhanced */
  .grid-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .grid-item {
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
  }

  /* Fixed home button at the top */
  .home-button {
    position: fixed;
    top: 10px;
    left: 10px;
    padding: 10px 20px;
    font-size: 18px;
    z-index: 100;
  }
}

@media only screen and (max-width: 480px) {
  body {
    padding-top: 60px; /* Slightly less space needed for smaller button */
  }

  h1 {
    font-size: 1.5rem;
  }

  .puzzle-container {
    padding: 0.75rem;
  }

  .grid-container {
    grid-template-columns: repeat(2, 1fr);
  }

  .constraint {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  .buttons {
    gap: 10px;
  }

  button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  /* Smaller home button for very small screens */
  .home-button {
    padding: 8px 16px;
    font-size: 16px;
  }
}
