:root {
  --ink: #1d2b34;
  --muted: #6b7a82;
  --line: #d6dde1;
  --accent: #1565c0;
  --accept: #2e7d32;
  --accept-bg: #f1f8f1;
  --reject: #c62828;
  --reject-bg: #fdf3f2;
  --grid: #555b60;
  --cell: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 32px 20px 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  line-height: 1.55;
  background: #fafbfc;
}

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

h1 {
  font-size: 26px;
  margin: 0 0 4px;
}

h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 30px 0 12px;
}

h2.accept-heading {
  color: var(--accept);
}

h2.reject-heading {
  color: var(--reject);
}

p {
  margin: 0 0 14px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.back {
  margin-bottom: 18px;
}

.progress {
  color: var(--muted);
  font-weight: 600;
}

.solved-banner {
  padding: 12px 16px;
  background: var(--accept-bg);
  border: 1px solid var(--accept);
  border-radius: 8px;
  color: var(--accept);
}

.score-line {
  font-size: 15px;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.banner-warn {
  background: var(--reject-bg);
  border: 1px solid var(--reject);
  color: var(--reject);
}

.banner-close {
  flex: none;
  margin: 0;
  padding: 0 8px;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.banner-close:hover {
  opacity: 0.7;
}

/* --- buttons --- */
button {
  font: inherit;
  padding: 9px 18px;
  margin: 0 10px 0 0;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  cursor: pointer;
}

button:hover {
  opacity: 0.92;
}

button.secondary {
  background: #fff;
  color: var(--accent);
}

.actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

/* --- the editable board --- */
.centered-container {
  text-align: center;
  margin: 28px 0;
}

#editable-section {
  display: flex;
  justify-content: center;
}

#candidate-grid,
.mini-grid {
  border-collapse: collapse;
}

#candidate-grid {
  /* Drag-to-paint surface: don't scroll or select text while drawing. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#candidate-grid td,
.mini-grid td {
  padding: 0;
}

.bit-cell {
  display: block;
  width: var(--cell);
  height: var(--cell);
  border: 1px solid var(--grid);
  background: #fff;
  cursor: pointer;
}

.bit-cell:hover {
  background: #eef3f8;
}

.bit-cell.on {
  background: #000;
}

.bit-square {
  display: block;
  width: var(--cell);
  height: var(--cell);
  border: 1px solid var(--grid);
  background: #fff;
}

/* Highlight the most recently submitted board in the galleries. */
.mini-grid.highlight {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* In-button spinner shown while a submit is in flight. */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

button.secondary .spinner {
  border: 2px solid rgba(21, 101, 192, 0.3);
  border-top-color: var(--accent);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.shuffle-disclaimer {
  color: var(--reject);
  font-weight: 600;
}

/* --- read-only galleries (accepted / rejected / challenge) --- */
.grid-gallery,
.challenge-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.mini-grid {
  display: inline-table;
}

.challenge-wrapper {
  text-align: center;
}

.challenge-label {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  cursor: pointer;
}

#challenge-section {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

#submit-challenge-button {
  margin-top: 16px;
}

/* --- menu --- */
.problem-menu {
  list-style: none;
  padding: 0;
  max-width: 420px;
}

.problem-menu li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.problem-menu li.solved {
  border-color: var(--accept);
  background: var(--accept-bg);
}

.problem-link {
  font-weight: 600;
}

.problem-menu .state {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.problem-menu li.solved .state-label {
  color: var(--accept);
  font-weight: 600;
}

.problem-menu .score {
  padding: 2px 8px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--accept);
  color: var(--accept);
}
