:root {
  --primary: #4a5568;
  --primary-light: #718096;
  --background: #f7fafc;
  --foreground: #2d3748;
  --muted: #edf2f7;
  --muted-foreground: #718096;
  --border: #e2e8f0;
  --input: #edf2f7;
  --ring: #cbd5e0;
  --error: #fc8181;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem;
}

header {
  text-align: center;
  padding: 1rem 0;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

select,
button {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
  background-color: var(--background);
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1em;
  padding-right: 2.5rem;
}

button {
  background-color: var(--primary);
  color: var(--background);
  font-weight: 600;
}

button:hover {
  background-color: var(--primary-light);
}

.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  max-width: 450px;
  margin: 0 auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 1px;
  background-color: var(--border);
  border: 2px solid var(--primary);
  border-radius: 0.25rem;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1;
}

.cell {
  background-color: var(--background);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.25rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease-in-out;
}

.cell:hover {
  background-color: var(--muted);
}

.cell.given {
  font-weight: 700;
  background-color: var(--muted);
}

.cell.selected {
  background-color: var(--ring);
}

.cell.invalid {
  color: var(--error);
}

.cell:nth-child(3n) {
  border-right: 2px solid var(--primary);
}

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

.game-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem;
  background-color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}

.number-button {
  aspect-ratio: 1;
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background-color: var(--background);
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  padding: 0;
}

.number-button:hover {
  background-color: var(--muted);
}

.stats {
  background-color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 1rem;
  width: 100%;
}

.stats h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.stats p {
  margin: 0.5rem 0;
  font-size: 0.875rem;
  display: flex;
  justify-content: space-between;
}

.win-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  max-width: 90%;
  width: 300px;
  display: none;
}

.win-modal.show {
  display: block;
}

.win-modal h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.win-modal p {
  margin-bottom: 1rem;
}

.content-section {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.content-section h2 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.content-section h3 {
  font-size: 1.25rem;
  color: var(--primary-light);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.content-section p {
  margin-bottom: 1rem;
  line-height: 1.6;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}

.feature-card {
  background-color: var(--muted);
  border-radius: 0.5rem;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.feature-card h3 {
  margin-top: 0;
}

@media (min-width: 768px) {
  .game-area {
    flex-direction: row;
    align-items: flex-start;
    max-width: 800px;
    gap: 2rem;
  }

  .board {
    flex: 0 0 450px;
    width: 450px;
  }

  .game-controls {
    flex: 1;
    max-width: 300px;
  }
}

@media (max-width: 767px) {
  .game-area {
    padding: 0 1rem;
  }

  .board {
    max-width: 450px;
    width: 100%;
  }

  .game-controls {
    max-width: 450px;
  }
}

footer {
  text-align: center;
  padding: 20px 0;
  margin-top: 40px;
}

footer .container {
  max-width: 1200px;
  margin: 0 auto;
}

footer p {
  margin: 0;
  color: #666;
}

.main-header {
  background: var(--background);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.5rem;
  margin-bottom: 2rem;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 1.125rem;
}

.logo img {
  border-radius: 4px;
}

.nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-link {
  color: var(--primary-light);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s ease-in-out;
}

.nav-link:hover {
  color: var(--primary);
}

@media (max-width: 768px) {
  .header-content {
    padding: 0 0.5rem;
  }

  .nav {
    gap: 1rem;
  }

  .nav-link {
    font-size: 0.8125rem;
  }
}
