/* Nonogram — own styles, theme variables only. Root class: .ng */

.ng {
  width: 100%;
  max-width: 640px;
}

.ng-bar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.ng-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ng-tools .gm-btn {
  min-height: 44px;
  touch-action: manipulation;
}

.ng-modebtn svg {
  width: 0.9em;
  height: 0.9em;
}

.ng-modebtn[aria-pressed="true"] {
  background: var(--gm-accent, #c0392b);
  border-color: var(--gm-accent, #c0392b);
  color: #fff;
}

.ng-stat {
  min-width: 84px;
  padding: 8px 14px 6px;
  text-align: center;
  border-radius: 10px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
}

.ng-stat b {
  display: block;
  font: 500 1.35rem/1.15 var(--gm-display, "Fraunces", Georgia, serif);
  font-variant-numeric: tabular-nums;
}

.ng-lab {
  display: block;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gm-muted, rgba(242, 238, 230, 0.66));
}

/* The grid scrolls sideways only when 18 px cells still do not fit (narrower than ~330 px). */
.ng-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px;
  box-sizing: border-box;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-radius: var(--gm-radius, 12px);
  -webkit-overflow-scrolling: touch;
}

.ng-grid {
  --n: 10;
  --cell: 32px;
  display: grid;
  grid-template-columns: auto repeat(var(--n), var(--cell));
  grid-template-rows: auto repeat(var(--n), var(--cell));
  width: max-content;
  margin: 0 auto;
  border: 2px solid var(--gm-line-2, rgba(255, 255, 255, 0.16));
  border-radius: 4px;
  background: var(--gm-bg-2, #131c2b);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.ng-corner,
.ng-clue,
.ng-cell {
  box-sizing: border-box;
  border-right: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-bottom: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
}

.ng-corner {
  background: var(--gm-surface, #1b2740);
  border-right-width: 2px;
  border-bottom-width: 2px;
  border-color: var(--gm-line-2, rgba(255, 255, 255, 0.16));
}

.ng-clue {
  display: flex;
  gap: 0.35em;
  padding: 3px 5px;
  font: 600 clamp(11px, calc(var(--cell) * 0.5), 15px)/1.15 var(--gm-body, "DM Sans", system-ui, sans-serif);
  font-variant-numeric: tabular-nums;
  color: var(--gm-text, #f2eee6);
  background: var(--gm-surface, #1b2740);
  transition: color 0.2s ease;
}

.ng-clue.ng-col {
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-height: calc(var(--cell) * 1.2);
  border-bottom-width: 2px;
  border-bottom-color: var(--gm-line-2, rgba(255, 255, 255, 0.16));
}

.ng-clue.ng-row {
  justify-content: flex-end;
  align-items: center;
  min-width: calc(var(--cell) * 1.2);
  padding-right: 7px;
  border-right-width: 2px;
  border-right-color: var(--gm-line-2, rgba(255, 255, 255, 0.16));
}

.ng-clue.is-done {
  color: var(--gm-muted, rgba(242, 238, 230, 0.66));
  opacity: 0.45;
}

.ng-cell {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  width: var(--cell);
  height: var(--cell);
  border-top: 0;
  border-left: 0;
  background: var(--gm-surface, #1b2740);
  cursor: pointer;
  touch-action: none;
}

.ng-cell:hover { background: var(--gm-surface-2, #22304a); }

/* thicker lines every five cells */
.ng-cell.is-b5,
.ng-clue.ng-col.is-b5 { border-right: 2px solid var(--gm-line-2, rgba(255, 255, 255, 0.16)); }
.ng-cell.is-r5,
.ng-clue.ng-row.is-r5 { border-bottom: 2px solid var(--gm-line-2, rgba(255, 255, 255, 0.16)); }

.ng-cell.is-fill,
.ng-cell.is-fill:hover { background: var(--gm-text, #f2eee6); }

.ng-cell.is-x::before,
.ng-cell.is-x::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 55%;
  height: 2px;
  background: var(--gm-muted, rgba(242, 238, 230, 0.66));
  transform: translate(-50%, -50%) rotate(45deg);
  opacity: 0.8;
}
.ng-cell.is-x::after { transform: translate(-50%, -50%) rotate(-45deg); }

.ng-cell.is-wrong,
.ng-cell.is-wrong:hover {
  background: var(--gm-wrong, #e0584a);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.ng-cell:focus-visible {
  outline: 3px solid var(--gm-accent-bright, #e0584a);
  outline-offset: -3px;
  z-index: 2;
}

/* the finished picture */
.ng-grid.is-solved .ng-cell { cursor: default; }
.ng-grid.is-solved .ng-cell.is-fill { background: var(--gm-accent, #c0392b); }
.ng-grid.is-solved .ng-cell.is-x::before,
.ng-grid.is-solved .ng-cell.is-x::after { display: none; }
.ng-grid.is-solved .ng-clue { opacity: 0.45; color: var(--gm-muted, rgba(242, 238, 230, 0.66)); }

.ng .gm-status { margin-top: 12px; }

.gm-seg button,
.gm-actions .gm-btn { min-height: 44px; }

@media (max-width: 991px) {
  .ng { margin: 0 auto; }
}

@media (max-width: 480px) {
  .ng-bar { gap: 6px; }
  .ng-stat { min-width: 66px; padding: 8px 8px 6px; }
  .ng-tools { gap: 6px; }
  .ng-tools .gm-btn { padding: 10px 12px; }
  .ng-scroll { padding: 4px; }
  .ng-clue { gap: 0.25em; font-size: clamp(10px, calc(var(--cell) * 0.5), 15px); }
  .ng-clue.ng-row { padding: 2px 5px 2px 3px; }
  .ng-clue.ng-col { padding: 3px 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .ng-clue { transition: none; }
}
