*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, #4f46e5 0, #0f172a 55%, #020617 100%);
  color: #0f172a;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.app {
  width: 100%;
  max-width: 640px;
  padding: 16px;
  background: rgba(248, 250, 252, 0.96);
  border-radius: 18px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.6);
  backdrop-filter: blur(16px);
}

.app-header {
  text-align: center;
  margin-bottom: 12px;
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.controls select,
.controls button {
  padding: 4px 8px;
  font-size: 0.9rem;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-top: 4px;
}

.status-bar #message {
  color: #d9534f;
}

.hint {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #6b7280;
}

.sudoku-grid {
  margin: 12px auto;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  max-width: 480px;
  background: linear-gradient(135deg, #e5e7eb, #f9fafb);
  border-radius: 12px;
  padding: 4px;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.7);
}

.cell {
  width: 100%;
  padding-top: 100%;
  position: relative;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.08s ease;
}

.cell.readonly {
  font-weight: 600;
}

.cell.selected {
  box-shadow: 0 0 0 2px #4f46e5;
  z-index: 1;
}

.cell:hover {
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.8);
  transform: translateY(-1px);
}

.cell-inner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.cell-input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 500;
  background: transparent;
  color: #111827;
}

.cell.readonly .cell-input {
  cursor: default;
}

/* 3x3 宫块配色 */
.cell.block-0,
.cell.block-2,
.cell.block-4,
.cell.block-6,
.cell.block-8 {
  background: #f9fafb;
}

.cell.block-1,
.cell.block-3,
.cell.block-5,
.cell.block-7 {
  background: #eef2ff;
}

.cell.block-0,
.cell.block-4,
.cell.block-8 {
  background: #e0f2fe;
}

.cell.block-1,
.cell.block-3,
.cell.block-5,
.cell.block-7 {
  background: #dcfce7;
}

.cell.block-2,
.cell.block-6 {
  background: #fef9c3;
}

.cell.readonly {
  font-weight: 700;
}

.cell.conflict {
  background: #fecaca !important;
}

/* 粗分隔线：3x3 区块 */
.cell[data-right-bold="true"] {
  border-right-width: 2px;
}

.cell[data-bottom-bold="true"] {
  border-bottom-width: 2px;
}

.number-pad {
  margin: 12px auto 0;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  opacity: 0.9;
}

.number-pad button {
  padding: 8px;
  font-size: 1rem;
  cursor: pointer;
}

button {
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.9);
  background: linear-gradient(135deg, #eef2ff, #e0f2fe);
  cursor: pointer;
  color: #111827;
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.08s ease,
    border-color 0.16s ease;
}

button:hover {
  background: linear-gradient(135deg, #e0e7ff, #bae6fd);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
}

button:active {
  background: linear-gradient(135deg, #c7d2fe, #7dd3fc);
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}

@media (max-width: 480px) {
  .app-header h1 {
    font-size: 1.3rem;
  }

  .cell-inner {
    font-size: 1rem;
  }
}
