.nonogram-page {
  --ng-paper: #f7f1e8;
  --ng-card: #fffaf2;
  --ng-ink: #2b2118;
  --ng-muted: #6b5b4b;
  --ng-accent: #c2562f;
  --ng-gold: #e0a03a;
  --ng-action: #963e25;
  --ng-line: #cab9a6;
  --ng-radius: 8px;
  --ng-heading: Georgia, 'Times New Roman', serif;
}

.nonogram-page .play-title {
  padding-bottom: 14px;
  border-bottom: 3px double var(--ng-ink);
}
.nonogram-page .play-title h1 {
  color: var(--ng-ink);
  font: bold clamp(32px, 5.5vw, 52px)/1.15 var(--ng-heading);
  letter-spacing: -.045em;
}
.nonogram-page .play-layout { display: block; }
.nonogram-page .game-stage { margin: 0; padding: 0; border: 0; border-radius: 0; background: none; }
.nonogram-page .stage-toolbar { justify-content: end; margin-bottom: 8px; }
.nonogram-page .stage-toolbar > span { display: none; }
.nonogram-page #game-root[aria-busy="false"] { min-height: 0; }
.nonogram-page .game-stage.focus-mode {
  padding: 12px max(16px, calc((100vw - 900px) / 2)) 24px;
  background: var(--ng-paper);
}
.nonogram-page .focus-mode #game-root { max-width: none; }
.nonogram-page :focus-visible { outline: 3px solid var(--ng-accent); outline-offset: 3px; }

.ng-game {
  color: var(--ng-ink);
  font: 16px/1.6 system-ui, -apple-system, sans-serif;
  display: grid;
  grid-template-columns: minmax(0, 1.68fr) minmax(238px, 1fr);
  gap: 20px;
  align-items: start;
}
.ng-play-panel, .ng-hint-panel {
  min-width: 0;
  border: 1px solid var(--ng-line);
  border-radius: var(--ng-radius);
  background: var(--ng-card);
}
.ng-play-panel { padding: 20px 24px; }
.ng-play-panel > :not(.ng-board) { max-width: 420px; margin-inline: auto; }
.ng-hint-panel {
  padding: 20px;
  border-top: 3px solid var(--ng-gold);
  background: #fff4df;
}
.ng-hint-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ng-hint-heading h2 { margin: 0; font: bold clamp(22px, 3.5vw, 27px)/1.15 var(--ng-heading); }
.ng-hint-panel p { margin: 0; color: var(--ng-muted); }
.ng-hint-panel > p, .ng-hint-panel .ng-hint-feedback { margin-top: 10px; }
.ng-hint-feedback p + p { margin-top: 8px; }
.ng-hint-feedback button { margin: 10px 6px 0 0; }
.ng-hint-feedback [data-ng-hint-detail] {
  padding: 12px;
  border-left: 3px solid var(--ng-gold);
  background: var(--ng-card);
  color: var(--ng-ink);
}

.ng-game button, .ng-game select { font: inherit; color: inherit; }
.ng-game button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.ng-game button:disabled { cursor: default; opacity: .5; }
.ng-game button:not(.ng-cell), .ng-game select {
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--ng-line);
  border-radius: 6px;
  background: var(--ng-card);
  font-size: 14px;
  line-height: 1.3;
}
.ng-game button:not(.ng-cell):not(:disabled):hover, .ng-game select:hover { border-color: var(--ng-action); }
.ng-game button[data-ng-hint], .ng-game button[data-ng-confirm] {
  padding-inline: 16px;
  border-color: var(--ng-action);
  background: var(--ng-action);
  color: white;
  font-weight: 700;
}
.ng-game button[data-ng-hint]:hover:not(:disabled), .ng-game button[data-ng-confirm]:hover:not(:disabled) { background: #79301c; }
.ng-game button[data-ng-why] { font-weight: 700; color: var(--ng-action); }
.ng-game button[data-ng-hint-dismiss] { border-color: transparent; background: transparent; }
.ng-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.ng-chooser-label { flex: 1; min-width: 0; font-size: 13px; font-weight: 650; }
.ng-chooser-label select { display: block; width: 100%; margin-top: 4px; font-weight: 600; }
.ng-progress { padding-bottom: 10px; color: var(--ng-muted); font-size: 13px; white-space: nowrap; }

.ng-board {
  --grid-rule: #c9b6a0;
  --clue-track: var(--ng-row-width, 42px);
  width: 100%;
  max-width: 420px;
  margin-inline: auto;
  padding: 4px;
  border: 1px solid #ae967d;
  border-radius: 5px;
  background: var(--grid-rule);
  user-select: none;
}
.ng-row { display: grid; grid-template-columns: var(--clue-track) repeat(var(--ng-cols, 5), minmax(0, 1fr)); }
.ng-top { min-height: calc(var(--ng-clue-depth, 1) * 18px + 12px); }
.ng-cell, .ng-col-clue, .ng-row-clue, .ng-corner {
  min-width: 0;
  border: 0;
  border-top: 1px solid var(--grid-rule);
  border-left: 1px solid var(--grid-rule);
}
.ng-col-clue, .ng-row-clue, .ng-corner {
  display: flex;
  justify-content: end;
  align-items: center;
  background: #eee2d3;
  color: #594534;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ng-row-clue { padding-inline: 2px 6px; white-space: pre; }
.ng-col-clue { flex-direction: column; padding-block: 4px; line-height: 18px; }
.ng-corner { align-items: end; justify-content: center; padding-bottom: 3px; }
.ng-highlight { background: #f5dfb6; }
.ng-matches { background: #e6e8d4; color: #42513a; }
.ng-row > :nth-child(5n + 7) { border-left: 2px solid #8f7155; }
.ng-row:nth-child(5n + 7) > * { border-top: 2px solid #8f7155; }
.ng-game .ng-cell {
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  aspect-ratio: 1;
  border-radius: 0;
  background: #fffdf7;
  font-size: clamp(18px, 4.5vw, 28px);
  line-height: 1;
}
.ng-game .ng-cell.ng-filled { background: var(--ng-ink); }
.ng-game .ng-cell.ng-marked { background: #f1e6d9; color: #684b36; }
.ng-cell.ng-active { outline: 2px solid #9e662f; outline-offset: -2px; }
.ng-cell.ng-filled.ng-active { outline-color: var(--ng-gold); }
.nonogram-page .ng-cell:focus-visible { position: relative; z-index: 1; outline-offset: -3px; }
.ng-game .ng-cell.ng-hint-line:not(.ng-filled), .ng-col-clue.ng-hint-line, .ng-row-clue.ng-hint-line {
  background: #fbe7bc;
  color: var(--ng-ink);
}
.ng-game .ng-cell.ng-filled.ng-hint-line { box-shadow: inset 0 0 0 1px #c68b47; }
.ng-game .ng-cell.ng-hint-target {
  background: #f7cb78;
  outline: 3px dashed var(--ng-action);
  outline-offset: -4px;
}
@media (hover: hover) {
  .ng-game .ng-cell:hover { box-shadow: inset 0 0 0 2px #b88859; }
}

.ng-play-controls { margin-top: 12px; }
.ng-modes, .ng-tools { display: flex; justify-content: center; gap: 8px; }
.ng-modes button, .ng-tools button { flex: 1; min-width: 0; font-weight: 650; }
.ng-modes button span { margin-right: 4px; font-size: 16px; }
.ng-game .ng-modes button[aria-pressed="true"] { background: var(--ng-ink); color: var(--ng-card); border-color: var(--ng-ink); }
.ng-tools { margin-top: 8px; }
.ng-selected, .ng-status { margin-block: 8px; text-align: center; color: var(--ng-muted); font-size: 13px; line-height: 1.45; }
.ng-selected { font-variant-numeric: tabular-nums; }
.ng-footnote { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; color: var(--ng-muted); font-size: 13px; }
.ng-complete {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #b8bfaa;
  border-radius: 6px;
  background: #e9ebd9;
}
.ng-complete > span { color: #5b653f; }
.ng-complete p { font-size: 13px; line-height: 1.45; }
.ng-complete button { margin-left: auto; }
.ng-confirm {
  width: min(100% - 28px, 384px);
  padding: 20px;
  border: 1px solid var(--ng-line);
  border-radius: var(--ng-radius);
  background: var(--ng-card);
  color: var(--ng-ink);
  box-shadow: 0 8px 24px #2b211830;
}
.ng-confirm::backdrop { background: #2b211875; }
.ng-confirm p { margin-block: 8px 16px; }
.ng-confirm > div { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }

.nonogram-example { margin: 16px 0 0; padding: 16px; border: 1px solid var(--ng-line); border-radius: var(--ng-radius); background: var(--ng-card); }
.nonogram-example-line {
  display: grid;
  grid-template-columns: minmax(32px, 1.2fr) repeat(5, minmax(0, 1fr));
  max-width: 264px;
  gap: 2px;
  margin-bottom: 12px;
  padding: 2px;
  border: 1px solid var(--ng-line);
  background: var(--ng-line);
}
.nonogram-example-clue, .nonogram-example-cell { display: grid; place-items: center; background: #fffdf7; }
.nonogram-example-clue { background: #eee2d3; font-size: 14px; font-weight: 700; }
.nonogram-example-cell { aspect-ratio: 1; }
.nonogram-example-fill { background: var(--ng-ink); }
.nonogram-example-cross { background: #f1e6d9; color: #684b36; font-size: 20px; }
.nonogram-example figcaption { color: var(--ng-muted); font-size: 14px; }

@media (max-width: 760px) {
  .ng-game { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .ng-play-panel, .ng-hint-panel { padding: 12px; }
  .ng-board { --clue-track: min(var(--ng-row-width, 42px), 50px); }
  .ng-toolbar { margin-bottom: 8px; }
  .ng-selected, .ng-status { margin-block: 6px; }
}

@media (max-width: 440px) {
  .nonogram-page { padding-inline: 10px; }
  .nonogram-page .game-stage.focus-mode { padding-inline: 10px; }
  .ng-play-panel { padding: 9px; }
  .ng-board { --clue-track: min(var(--ng-row-width, 42px), 44px); padding: 3px; }
  .ng-chooser-label select { padding-inline: 8px; }
  .ng-col-clue, .ng-row-clue, .ng-corner { font-size: 12px; }
  .ng-row-clue { justify-content: center; padding: 0; }
  .ng-modes, .ng-tools { gap: 5px; }
  .ng-game .ng-modes button, .ng-game .ng-tools button { padding-inline: 4px; }
  .ng-complete { gap: 6px; }
  .ng-complete > span { display: none; }
}

.ng-mode-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.ng-mode-tabs button { min-height: 38px; font-weight: 700; padding: 6px; }
.ng-mode-tabs button[aria-selected="true"] { background: var(--ng-ink); color: var(--ng-card); border-color: var(--ng-ink); }
.ng-unlimited-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ng-unlimited-bar[hidden] { display: none; }
.ng-size-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.ng-size-pills button[aria-pressed="true"] { background: var(--ng-action); color: #fff; border-color: var(--ng-action); font-weight: 700; }
.ng-dynamic-title { font-size: 14px; font-weight: 700; padding-bottom: 8px; }
.ng-board[data-cols="15"] { max-width: 500px; }
.ng-board[data-cols="15"] .ng-col-clue, .ng-board[data-cols="15"] .ng-row-clue { font-size: 11px; line-height: 13px; }
.ng-board[data-cols="15"] .ng-cell { font-size: 14px; }
.ng-complete { flex-wrap: wrap; }
.ng-complete-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.ng-next-daily { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 12px; border-radius: 6px; background: var(--ng-action); color: #fff !important; font-size: 13px; font-weight: 700; text-decoration: none; }
