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

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
  color: white;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

.controls {
  background: white;
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.difficulty-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.difficulty-selector label {
  font-weight: 600;
  color: #555;
}

.difficulty-selector select {
  padding: 8px 12px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  background: white;
  cursor: pointer;
  transition: border-color 0.3s ease;
}

.difficulty-selector select:focus {
  outline: none;
  border-color: #667eea;
}

.buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn.secondary {
  background: #f8f9fa;
  color: #555;
  border: 2px solid #ddd;
}

.btn.secondary:hover {
  background: #e9ecef;
  border-color: #adb5bd;
  transform: translateY(-1px);
}

.game-container {
  display: flex;
  gap: 30px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

.sudoku-board {
  background: white;
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 1px;
  border: 3px solid #333;
  max-width: 450px;
  width: 100%;
}

.cell {
  width: 45px;
  height: 45px;
  border: 1px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: white;
  position: relative;
}

.cell:hover {
  background: #f0f8ff;
}

.cell.selected {
  background: #e3f2fd;
  border-color: #2196f3;
}

.cell.fixed {
  background: #f5f5f5;
  color: #333;
  cursor: not-allowed;
  font-weight: 700;
}

.cell.error {
  background: #ffebee;
  color: #d32f2f;
}

.cell.user-input {
  color: #1976d2;
}

/* 3x3 box borders */
.cell:nth-child(3n) {
  border-right: 2px solid #333;
}

.cell:nth-child(9n) {
  border-right: 3px solid #333;
}

.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 2px solid #333;
}

.cell:nth-child(n + 28):nth-child(-n + 36),
.cell:nth-child(n + 55):nth-child(-n + 63) {
  border-top: 2px solid #333;
}

.game-info {
  background: white;
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  min-width: 200px;
}

.game-info > div {
  margin-bottom: 15px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
  font-weight: 600;
}

.game-info span:first-child {
  color: #666;
}

.instructions {
  background: white;
  padding: 25px;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  margin-top: 30px;
}

.instructions h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.instructions ul {
  list-style: none;
  padding-left: 0;
}

.instructions li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  position: relative;
  padding-left: 25px;
}

.instructions li:before {
  content: "•";
  color: #667eea;
  font-weight: bold;
  position: absolute;
  left: 0;
}

.instructions li:last-child {
  border-bottom: none;
}

/* Victory Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
}

.modal-content {
  background: white;
  margin: 10% auto;
  padding: 30px;
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.victory-header h2 {
  color: #667eea;
  font-size: 2rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(102, 126, 234, 0.2);
}

.victory-header p {
  color: #666;
  font-size: 1.2rem;
  margin-bottom: 25px;
}

.victory-stats {
  display: flex;
  justify-content: space-around;
  margin: 25px 0;
  padding: 20px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 15px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.stat-label {
  font-weight: 600;
  color: #666;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #333;
}

.victory-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 25px;
}

.victory-actions .btn {
  min-width: 120px;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  header h1 {
    font-size: 2rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .buttons {
    justify-content: center;
  }

  .game-container {
    flex-direction: column;
    align-items: center;
  }

  .sudoku-board {
    max-width: 350px;
  }

  .cell {
    width: 35px;
    height: 35px;
    font-size: 1rem;
  }

  .modal-content {
    margin: 20% auto;
    padding: 20px;
  }

  .victory-stats {
    flex-direction: column;
    gap: 15px;
  }

  .victory-actions {
    flex-direction: column;
  }

  .victory-actions .btn {
    min-width: auto;
  }
}

@media (max-width: 480px) {
  .sudoku-board {
    max-width: 300px;
  }

  .cell {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  .btn {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .modal-content {
    margin: 10% auto;
    padding: 15px;
  }

  .victory-header h2 {
    font-size: 1.5rem;
  }
}

/* Book Modal Styles */
.book-header h2 {
  color: #667eea;
  font-size: 1.8rem;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(102, 126, 234, 0.2);
}

.book-header p {
  color: #666;
  font-size: 1rem;
  margin-bottom: 20px;
}

.book-form {
  margin: 20px 0;
}

.form-group {
  margin-bottom: 15px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  color: #333;
  font-weight: 600;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.book-actions {
  margin-top: 25px;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.book-actions .btn {
  min-width: 120px;
}
