:root{
  --bg:#fff;
  --card:#fff;
  --text:#111;
  --muted:#666;
  --line:#e6e6e6;
  --chip:#f3f3f3;
  --accent:#0b57d0;
  --danger:#c62828;
}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
}

.ng{
  max-width:980px;
  margin:14px auto;
  padding:14px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--card);
}

h2{ margin:10px 0 10px; }
.lb{ margin:0 0 14px; padding:12px; border:1px solid var(--line); border-radius:14px; background:#fafafa; }
.lb-sub{ margin:6px 0 10px; color:var(--muted); font-size:.95rem; }

.toolbar{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  background:#fafafa;
  margin-bottom:12px;
}

.row{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin:8px 0; }
.row label{ color:var(--muted); min-width:62px; }

.chip{
  border:1px solid var(--line);
  background:var(--chip);
  border-radius:999px;
  padding:8px 12px;
  cursor:pointer;
}
.chip.active{ border-color:var(--accent); box-shadow:0 0 0 2px rgba(11,87,208,.12) inset; }
.chip[aria-disabled="true"]{ opacity:.55; cursor:not-allowed; }

.stats-row{ gap:14px; }
.stat{ background:#fff; border:1px solid var(--line); border-radius:12px; padding:8px 10px; }
.stat b{ display:block; font-size:1.05rem; margin-top:2px; }
.stat.small b{ font-size:1rem; }

.buttons-row{ gap:8px; }
button.primary{
  background:var(--accent);
  color:#fff;
  border:0;
  padding:10px 14px;
  border-radius:12px;
  cursor:pointer;
}
button.ghost{
  background:#fff;
  border:1px solid var(--line);
  padding:10px 14px;
  border-radius:12px;
  cursor:pointer;
}

.board-area{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  background:#fff;
  overflow:auto;
}

.result{ margin:10px 0 0; color:var(--muted); }

.win{
  position:fixed; inset:0; background:rgba(0,0,0,.35);
  display:flex; align-items:center; justify-content:center;
  padding:14px; z-index:50;
}
.modal{
  width:min(520px, 100%);
  background:#fff;
  border-radius:16px;
  padding:14px;
  border:1px solid var(--line);
}
.modal .actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.modal input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  font-size:16px;
  margin-top:8px;
}

/* Nonogram board */
.ng-board{
  display:grid;
  grid-template-columns: auto 1fr;
  gap:10px;
}

/* we render a table-like grid in JS; keep it simple */
.ng-grid{
  display:grid;
  gap:1px;
  background:var(--line);
  border:1px solid var(--line);
  border-radius:10px;
  overflow:hidden;
}
.ng-cell{
  width:26px;
  height:26px;
  background:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  user-select:none;
  cursor:pointer;
  font-size:18px;
  line-height:1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ng-cell.filled{ background:#111; }
.ng-cell.marked{ background:#fff; color:#999; }
.ng-cell.marked::after{ content:"✕"; font-size:16px; }

.ng-clues{
  display:flex;
  gap:8px;
  color:var(--muted);
  font-size:12px;
  line-height:1.2;
}

.ng-clues-col{ display:flex; gap:1px; align-items:flex-end; }
.ng-col{
  width:26px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-end;
  gap:2px;
}

.ng-clues-row{ display:flex; flex-direction:column; gap:1px; }
.ng-row{
  height:26px;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:4px;
  padding-right:6px;
  min-width:120px;
}
.ng-row span, .ng-col span{
  display:inline-block;
  padding:1px 2px;
  border-radius:6px;
}

body.dark{
  --bg:#0f1115;
  --card:#151923;
  --text:#f2f4f8;
  --muted:#b5bfd0;
  --line:#2a3140;
  --chip:#1c2230;
  --accent:#66a3ff;
}
body.dark .lb, body.dark .toolbar{ background:#111622; }
body.dark .board-area{ background:#0f1115; }
body.dark .ng-cell{ background:#0f1115; }
body.dark .ng-cell.filled{ background:#f2f4f8; }
body.dark .modal{ background:#151923; }
