:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #11213b;
  --accent: #1b7fdd;
  --accent-2: #0f5ca3;
  --ok: #1a9b5f;
  --muted: #5b6b84;
  --line: #d7e1ef;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top right, #e5f1ff, var(--bg));
  color: var(--ink);
}
.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px;
}
.top h1 { margin: 0; font-size: 2rem; }
.top p { margin-top: 6px; color: var(--muted); }
.difficulty-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.difficulty-row label {
  font-weight: 700;
  color: var(--ink);
}
.difficulty-row select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 14px 0 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}
button:hover { background: var(--accent-2); }

.game {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.game-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.game-actions { display: flex; gap: 8px; }
.hidden { display: none; }

.board-grid {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  width: max-content;
}
.cell {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 1.2rem;
  font-weight: 800;
}
.cell.light-on { background: #ffd54a; }
.cell.light-off { background: #1c2f52; color: #fff; }
.cell.fixed { background: #e8eef7; color: #243d63; }
.cell.binary { background: #fff; color: #243d63; }

@media (max-width: 600px) {
  .cell { width: 48px; height: 48px; }
  .stats { grid-template-columns: 1fr; }
}
