.nonogram-play { --game-play-width: 560px; }
.nonogram-toolbar, .nonogram-stats, .nonogram-modes, .nonogram-actions, .nonogram-victory-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.nonogram-toolbar, .nonogram-stats, .nonogram-status {
  color: var(--game-secondary);
  line-height: 1.6;
  font-size: 14px;
}
.nonogram-toolbar select { min-width: 0; max-width: 100%; }
.nonogram-stats {
  gap: 5px clamp(10px, 2vw, 24px);
  margin: 13px 0 10px;
  font-variant-numeric: tabular-nums;
}
.nonogram-stats strong { margin-inline-start: 2px; color: var(--game-ink); white-space: nowrap; }
.nonogram-tray {
  --number-bg: #e2eee8;
  --number-done: #27705a;
  --number-done-bg: #d2e9da;
  --board-border: #aabeb7;
  --cell-grid: #c7dbd1;
  --cell-bg: #fbfdfb;
  --cell-fill: #2d6c62;
  --cross: #56706e;
  --strong-grid: #7f9e95;
  box-sizing: border-box;
  width: min(100%, 492px);
  padding: clamp(5px, 1.7vw, 10px);
  margin-inline: auto;
  background: #eff6f1;
  border: 1px solid #bacfc5;
  border-radius: 10px;
}
.nonogram-tray[data-small] { max-width: 354px; }
html[data-theme=dark] .nonogram-tray {
  --number-bg: #294439;
  --number-done: #b1e4ab;
  --number-done-bg: #315345;
  --board-border: #47605a;
  --cell-grid: #3e5850;
  --cell-bg: #21352e;
  --cell-fill: #75b8a2;
  --cross: #aac8bd;
  --strong-grid: #91ad9d;
  background: #243d33;
  border-color: #49665a;
}
.nonogram-board {
  display: grid;
  grid-template-columns: calc(var(--side) * 1.28em + .35em) repeat(var(--size), minmax(0, 1fr));
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--board-border);
  border-radius: 4px;
  box-sizing: border-box;
  background: var(--cell-grid);
  font-size: clamp(10px, 2.8vw, 14px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.nonogram-corner, .nonogram-clue {
  background: var(--number-bg);
  min-width: 0;
}
.nonogram-clue {
  display: flex;
  align-items: center;
  gap: .17em;
  padding: .16em .27em;
  border: solid var(--cell-grid);
  border-width: 0 1px 1px 0;
  color: var(--game-ink);
  box-sizing: border-box;
}
.nonogram-clue[data-axis=row] { justify-content: flex-end; }
.nonogram-clue[data-axis=column] { flex-direction: column; justify-content: flex-end; min-height: 1.6em; }
.nonogram-clue[data-complete] { color: var(--number-done); background: var(--number-done-bg); }
.nonogram-cell {
  display: grid;
  place-content: center;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  position: relative;
  color: var(--cross);
  background: var(--cell-bg);
  border: solid var(--cell-grid);
  border-width: 0 1px 1px 0;
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nonogram-cell[data-divider-column] { border-inline-end-color: var(--strong-grid); }
.nonogram-cell[data-divider-row] { border-block-end-color: var(--strong-grid); }
.nonogram-cell[data-state="1"] { background: var(--cell-fill); }
.nonogram-cell[data-state="2"]::before {
  content: "×";
  font-size: clamp(14px, 4vw, 24px);
  line-height: 1;
  font-weight: 400;
}
.nonogram-cell[data-hint]::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px dashed #d39020;
  background: #ffe29325;
  pointer-events: none;
}
.nonogram-cell:focus-visible {
  outline: 2px solid #4b83ec;
  outline-offset: -3px;
  z-index: 1;
}
.nonogram-board[data-won] .nonogram-cell[data-state="1"] { background: var(--art-color); }
.nonogram-board[data-won] .nonogram-cell[data-state="2"]::before { content: none; }
.nonogram-modes { margin-top: 14px; }
body[data-fourhao-game=nonogram] .nonogram-modes [aria-pressed=true] {
  background: var(--game-accent-soft);
  border-color: var(--game-accent);
  color: var(--game-accent);
}
.nonogram-mode-fill { width: 12px; height: 12px; border-radius: 2px; background: currentColor; }
.nonogram-mode-empty { font-size: 19px; line-height: .75; }
.nonogram-actions { margin-top: 10px; }
.nonogram-status { min-height: 1.6em; margin: 9px 0 0; text-align: center; }
#show-victory[hidden], #next-level[hidden] { display: none; }
.nonogram-victory {
  box-sizing: border-box;
  width: min(420px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--game-line);
  border-radius: 14px;
  color: var(--game-secondary);
  background: var(--game-surface);
  box-shadow: 0 18px 54px #14243840;
  overscroll-behavior: contain;
}
.nonogram-victory::backdrop { background: #1326348c; }
.nonogram-victory-body { padding: 24px clamp(18px, 6vw, 32px); text-align: center; }
.nonogram-victory h2 { margin: 0; color: var(--game-accent); font-size: 22px; line-height: 1.45; }
.nonogram-victory p { margin: 9px 0 16px; line-height: 1.65; }

@media (prefers-reduced-motion: no-preference) {
  .nonogram-victory[open] { animation: nonogram-result-in 240ms ease-out; }
  @keyframes nonogram-result-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 440px) {
  body[data-fourhao-game=nonogram] :is(.nonogram-actions, .nonogram-modes) .game-page-button {
    min-height: 44px;
    padding-inline: 11px;
  }
}
