/* Nonogram — page-specific styles layered on top of app.css.
   Board needs clue gutters (a row of column clues above, a column of row clues to the left)
   which app.css's plain NxN .board/.cell rules don't provide, so the whole board is built
   from scratch here as a (size+1) x (size+1) CSS grid: one corner cell, one clue row, one
   clue column, then the size x size play cells. Cell + gutter sizes are set as CSS custom
   properties per-difficulty from JS (nonogram-app.js buildBoard()), since 5x5/10x10/15x15
   need very different cell sizes to stay usable. */

body.page-nonogram .board-shell,
body.page-nonogram .pad,
body.page-nonogram .mode-bar,
body.page-nonogram .statline {
  max-width: 640px;
}

.nono-shell {
  display: flex;
  justify-content: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.nono-grid {
  display: grid;
  gap: 0;
  background: var(--grid-line);
  border: 1px solid var(--box-line);
  border-radius: var(--r-md);
  width: max-content;
  height: max-content;
  overflow: hidden;
}

.nono-corner {
  background: var(--surface-2);
}

.nono-clue {
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex;
  user-select: none;
}

.nono-clue-col {
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 2px 1px 3px;
  line-height: 1.05;
  border-left: 1px solid var(--grid-line);
}

.nono-clue-col span {
  font-size: clamp(10px, calc(var(--nono-cell, 32px) * 0.3), 14px);
  line-height: 1.15;
}

.nono-clue-row {
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  border-top: 1px solid var(--grid-line);
}

.nono-clue-row span {
  font-size: clamp(10px, calc(var(--nono-cell, 32px) * 0.34), 15px);
}

/* Dims once the player's current fills in that line exactly match its clue — a quiet
   "this line is done" signal, independent of whether the rest of the board is right. */
.nono-clue.done {
  color: var(--ink-3);
  opacity: 0.4;
}

.nono-cell {
  background: var(--cell);
  border: none;
  border-left: 1px solid var(--grid-line);
  border-top: 1px solid var(--grid-line);
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  touch-action: none;
}

.nono-cell:hover { background: var(--cell-peer); }
.nono-cell.filled { background: var(--box-line); }
.nono-cell.filled:hover { background: color-mix(in srgb, var(--box-line) 88%, var(--brand)); }
.nono-cell.marked { color: var(--ink-3); }
.nono-cell.marked svg { width: 46%; height: 46%; }
.nono-cell.err { background: var(--cell-err-bg); }
.nono-cell.err.filled { background: var(--err); }
.nono-cell.sel { box-shadow: inset 0 0 0 2px var(--brand); z-index: 2; }
.nono-cell.pop { animation: pop .16s var(--ease); }
.nono-cell.hint-flash { animation: hintflash .9s var(--ease); }

/* Thicker line every 5 cells, both directions — standard nonogram convention so the eye can
   count position on bigger boards without losing track. */
.nono-cell.thick-r, .nono-clue-col.thick-r { border-right: 2.5px solid var(--box-line); }
.nono-cell.thick-b, .nono-clue-row.thick-b { border-bottom: 2.5px solid var(--box-line); }

.nono-toolbar {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto var(--sp-3);
}

.nono-toolbar .act {
  flex: 1;
  height: 46px;
}

.nono-toolbar .act svg { width: 19px; height: 19px; }

.nono-tip {
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 600;
  margin: 0 0 var(--sp-2);
}

@media (max-width: 980px) {
  body.page-nonogram .board-shell,
  body.page-nonogram .pad,
  body.page-nonogram .mode-bar,
  body.page-nonogram .statline,
  .nono-toolbar {
    max-width: 600px;
  }
}

@media (max-width: 768px) {
  .nono-shell { justify-content: flex-start; }
}

@media (max-width: 560px) {
  body.page-nonogram .mode-bar {
    flex-wrap: wrap;
    justify-content: center;
  }
  body.page-nonogram .mode-bar .seg { flex: 1 1 auto; justify-content: center; }
}
