:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body {
  margin: 0;
  background: #f8fafc;
  color: #0f172a;
}

.top-bar {
  display: flex;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: #0f172a;
}

.nav-button {
  border: none;
  background: #e2e8f0;
  color: #0f172a;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
}

.number-sums {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.puzzle-header h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 2.6rem);
}

.puzzle-intro {
  margin: 0.5rem 0 0;
  color: #334155;
  line-height: 1.6;
}

.puzzle-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.control-buttons button {
  border: none;
  background: #0f766e;
  color: #ffffff;
  padding: 0.6rem 1.2rem;
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.control-buttons button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(15, 118, 110, 0.18);
}

.control-buttons button:active {
  transform: translateY(0);
  box-shadow: none;
}

.solver-summary {
  font-size: 0.95rem;
  color: #1e293b;
}

.solver-summary.solver-warning {
  color: #b91c1c;
  font-weight: 600;
}

.puzzle-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 800px) {
  .puzzle-wrapper {
    flex-direction: row;
    align-items: flex-start;
    gap: 2rem;
  }
}

.grid-container {
  flex: 1 1 auto;
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.08);
}

.grid-table th,
.grid-table td {
  border: 1px solid #cbd5f5;
  text-align: center;
  padding: 0;
}

.grid-table th {
  background: #eef2ff;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
  color: #1e293b;
  min-width: 4.25rem;
}

.grid-table .corner-cell {
  background: #e2e8f0;
  border: none;
}

.grid-table .row-clue {
  text-align: left;
  padding: 0.5rem 0.75rem;
  min-width: 6.25rem;
}

.grid-table .clue-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.grid-table .clue-value {
  display: block;
  font-size: 1rem;
  margin-top: 0.2rem;
}

.grid-table .clue-met .clue-value {
  color: #0f766e;
  font-weight: 600;
}

.grid-table .clue-pending .clue-value {
  color: #1e293b;
}

.grid-table td {
  width: 4.25rem;
  height: 4.25rem;
}

.cell-button {
  width: 100%;
  height: 100%;
  border: none;
  font-size: 1.35rem;
  font-weight: 600;
  background: var(--region-color, #ffffff);
  color: #1e293b;
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease;
}

.cell-button:hover {
  transform: scale(1.02);
}

.cell-button:focus {
  outline: 3px solid rgba(59, 130, 246, 0.45);
  outline-offset: -3px;
}

.cell-button.state-selected {
  background: #0f766e;
  color: #ffffff;
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.35);
}

.cell-button:not(.state-selected) {
  color: #1f2937;
}

.cell-button.region-0 {
  --region-color: #fff5e6;
}

.cell-button.region-1 {
  --region-color: #e0f2ff;
}

.cell-button.region-2 {
  --region-color: #f0fdf4;
}

.cell-button.region-3 {
  --region-color: #fef2f2;
}

.cell-button.region-4 {
  --region-color: #fdf4ff;
}

.region-clues {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.region-title {
  margin: 0;
  font-size: 1.15rem;
  color: #1e293b;
}

.region-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.region-item {
  background: #ffffff;
  border-radius: 0.85rem;
  padding: 0.75rem 0.9rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.region-item .region-name {
  display: block;
  font-weight: 600;
  color: #0f172a;
}

.region-item .region-value {
  display: block;
  font-size: 0.95rem;
  margin-top: 0.25rem;
  color: #475569;
}

.region-item.clue-met .region-value {
  color: #0f766e;
  font-weight: 600;
}

.status-message {
  background: #ffffff;
  border-radius: 0.85rem;
  padding: 0.9rem 1.1rem;
  box-shadow: inset 0 0 0 1px #e2e8f0;
  font-size: 1rem;
  color: #0f172a;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}

.status-message.status-error {
  box-shadow: inset 0 0 0 2px rgba(248, 113, 113, 0.6);
  color: #b91c1c;
}

.status-message.status-success {
  box-shadow: inset 0 0 0 2px rgba(16, 185, 129, 0.45);
  color: #047857;
}

@media (max-width: 640px) {
  .grid-table th,
  .grid-table td {
    min-width: 3.25rem;
  }

  .grid-table td {
    width: 3.25rem;
    height: 3.25rem;
  }

  .cell-button {
    font-size: 1.15rem;
  }
}
