/* ============================================================================
   数织 Nonogram · 游戏专属样式
   选择器统一以 .g-nonogram 前缀限定，避免影响其他游戏
   ========================================================================== */

.g-nonogram {
  --ng-cell-bg: #dbe3f1;
  --ng-line: #a8b5ca;
  --ng-line-strong: #71819b;
  --ng-ink: #121826;
  --ng-ink-2: #202a3d;
  --ng-mark: #6c7b95;
  --ng-clue: #a9b9d3;
  --ng-clue-done: rgba(154, 164, 184, 0.32);
  gap: 10px;
  padding: 12px 10px calc(14px + var(--safe-b));
}

/* ------------------------------ 选关页 ------------------------------ */

.g-nonogram .ng-continue {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  text-align: left;
  transition: transform 0.1s ease, background 0.16s ease;
  min-height: 52px;
}
.g-nonogram .ng-continue:active { transform: scale(0.98); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.g-nonogram .ng-continue-k {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  padding: 2px 7px;
  flex: none;
}
.g-nonogram .ng-continue-n {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-nonogram .ng-continue-t {
  font-size: 11.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  flex: none;
}
.g-nonogram .ng-continue-a { font-size: 19px; line-height: 1; color: var(--faint); flex: none; }

.g-nonogram .ng-sec { display: flex; flex-direction: column; gap: 7px; }
.g-nonogram .ng-sec-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}
.g-nonogram .ng-sec-t {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--dim);
}
.g-nonogram .ng-sec-c { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.g-nonogram .ng-lv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.g-nonogram .ng-lv {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 82px;
  padding: 9px 5px 8px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));
  transition: transform 0.1s ease, border-color 0.16s ease, background 0.16s ease;
  touch-action: manipulation;
}
.g-nonogram .ng-lv:active { transform: scale(0.96); }
.g-nonogram .ng-lv.done {
  border-color: rgba(62, 207, 142, 0.34);
  background: linear-gradient(180deg, rgba(62, 207, 142, 0.13), rgba(62, 207, 142, 0.035));
}
.g-nonogram .ng-lv.locked { opacity: 0.48; background: rgba(255, 255, 255, 0.022); }
.g-nonogram .ng-lv-no {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.01em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.g-nonogram .ng-lv.done .ng-lv-no { color: var(--ok); }
.g-nonogram .ng-lv.locked .ng-lv-no { font-size: 14px; color: var(--faint); }
.g-nonogram .ng-lv-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-nonogram .ng-lv-meta {
  font-size: 9.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-nonogram .ng-lv.done .ng-lv-meta { color: rgba(62, 207, 142, 0.85); }
.g-nonogram .ng-lv-check {
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ok);
}
.g-nonogram .ng-foot-hint { text-align: center; padding: 2px 4px 0; }

/* ------------------------------ 对局页 ------------------------------ */

.g-nonogram .ng-stats .stat { padding: 8px 6px; }
.g-nonogram .ng-stats .stat-v { font-size: 16px; }

.g-nonogram .ng-ctrl { gap: 8px; align-items: stretch; }
.g-nonogram .ng-ctrl .seg { flex: 1; min-width: 0; }
.g-nonogram .ng-check-btn {
  flex: none;
  min-width: 86px;
  border-color: var(--line);
  color: var(--dim);
}
.g-nonogram .ng-check-btn.on {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
  background: color-mix(in srgb, var(--accent) 11%, transparent);
}

.g-nonogram .ng-board-wrap {
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.g-nonogram .ng-art-name {
  order: 2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-align: center;
  padding: 2px 0 0;
}

/* 棋盘：左上角空白 + 列线索 + 行线索 + 格子 */
.g-nonogram .ng-board {
  --cell: 24px;
  display: grid;
  grid-template-areas: "corner cols" "rows cells";
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  justify-content: center;
  align-content: center;
  margin: auto;
  flex: none;
  max-width: 100%;
}
.g-nonogram .ng-corner { grid-area: corner; }

.g-nonogram .ng-colclues {
  grid-area: cols;
  display: grid;
  grid-auto-rows: 1fr;
  align-items: end;
  justify-items: center;
}
.g-nonogram .ng-clue-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: var(--clue-gap, 2px);
  width: 100%;
  padding: 2px 0 4px;
}

.g-nonogram .ng-rowclues {
  grid-area: rows;
  display: grid;
  align-items: center;
  justify-items: end;
}
.g-nonogram .ng-clue-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--clue-gap, 2px);
  height: 100%;
  padding: 0 5px 0 2px;
}
.g-nonogram .ng-clue-num {
  font-style: normal;
  font-weight: 700;
  font-size: var(--clue-font, 12px);
  line-height: 1.05;
  color: var(--ng-clue);
  font-variant-numeric: tabular-nums;
  min-width: 0.62em;
  text-align: center;
  transition: color 0.15s ease;
}
.g-nonogram .ng-board[data-n="5"] { --clue-font: 16px; --clue-gap: 4px; }
.g-nonogram .ng-board[data-n="10"] { --clue-font: 12px; --clue-gap: 4px; }
.g-nonogram .ng-board[data-n="15"] { --clue-font: 10px; --clue-gap: 4px; }

.g-nonogram .ng-clue-row.active .ng-clue-num,
.g-nonogram .ng-clue-col.active .ng-clue-num {
  color: var(--accent);
  text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent);
}
.g-nonogram .ng-clue-row.done .ng-clue-num,
.g-nonogram .ng-clue-col.done .ng-clue-num {
  color: var(--ng-clue-done);
}
.g-nonogram .ng-clue-row.done.active .ng-clue-num,
.g-nonogram .ng-clue-col.done.active .ng-clue-num {
  color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-shadow: none;
}

/* 格子区 */
.g-nonogram .ng-cells-box {
  grid-area: cells;
  position: relative;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1.5px var(--ng-line-strong), 0 12px 28px -18px rgba(0, 0, 0, 0.9);
  transition: box-shadow 0.3s ease;
  touch-action: none;
}
.g-nonogram .ng-cells {
  display: grid;
  position: relative;
  z-index: 1;
  touch-action: none;
}
.g-nonogram .ng-cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ng-cell-bg);
  border-right: 1px solid var(--ng-line);
  border-bottom: 1px solid var(--ng-line);
  transition: background 0.1s ease;
  touch-action: none;
}
.g-nonogram .ng-cell.edge-r { border-right: 0; }
.g-nonogram .ng-cell.edge-b { border-bottom: 0; }
.g-nonogram .ng-cell.fill {
  background: var(--ng-ink);
  border-right-color: #2b3648;
  border-bottom-color: #2b3648;
}
.g-nonogram .ng-cell.mark::after {
  content: "×";
  color: var(--ng-mark);
  font-size: calc(var(--cell) * 0.82);
  font-weight: 500;
  line-height: 1;
  transform: translateY(-1px);
}
.g-nonogram .ng-cell.sel {
  box-shadow: inset 0 0 0 2px var(--accent);
  z-index: 2;
}
.g-nonogram .ng-cell.wrong { background: #ffb6bf; }
.g-nonogram .ng-cell.fill.wrong { background: #ff4155; }
.g-nonogram .ng-cell.mark.wrong { background: #ffd3d8; }
.g-nonogram .ng-cell.mark.wrong::after { color: #c81d33; }

/* 5 格粗分隔线 */
.g-nonogram .ng-lines { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.g-nonogram .ng-lines i { position: absolute; background: var(--ng-line-strong); }
.g-nonogram .ng-lines i.v { top: 0; bottom: 0; width: 2px; transform: translateX(-1px); }
.g-nonogram .ng-lines i.h { left: 0; right: 0; height: 2px; transform: translateY(-1px); }

/* 揭晓 */
.g-nonogram .ng-board.solved .ng-cells-box {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent),
    0 0 34px color-mix(in srgb, var(--accent) 26%, transparent),
    0 12px 28px -18px rgba(0, 0, 0, 0.9);
}
.g-nonogram .ng-board.solved .ng-cell.fill {
  background: linear-gradient(150deg, #2a3854, #0d121c 62%);
}
@media (prefers-reduced-motion: no-preference) {
  .g-nonogram .ng-cells.reveal .ng-cell.fill {
    animation: ng-pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
    animation-delay: 0ms;
  }
}
@keyframes ng-pop {
  0% { transform: scale(0.18); opacity: 0; }
  62% { transform: scale(1.07); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ------------------------------ 结算弹窗 ------------------------------ */

.ng-res-art {
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.04em;
  margin: 2px 0 12px;
  color: var(--accent);
}
.ng-res-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}
.ng-res-grid b {
  display: block;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  color: var(--text);
}
.ng-res-grid .hint { display: block; font-size: 10px; }
.ng-res-tip {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--warn);
}

/* 小屏（360）压缩一点间距 */
@media (max-width: 374px) {
  .g-nonogram { padding-left: 8px; padding-right: 8px; gap: 8px; }
  .g-nonogram .ng-lv { min-height: 76px; }
  .g-nonogram .ng-lv-no { font-size: 15px; }
  .g-nonogram .g-head-right .btn { padding: 6px 8px; }
}

/* 结算弹窗：下移 + 轻模糊，让上方揭晓的像素图案保持可见 */
.overlay.ng-result-overlay {
  align-items: flex-end;
  padding: 14px 16px calc(18px + var(--safe-b));
  background: rgba(4, 6, 11, 0.34);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.overlay.ng-result-overlay .dialog { padding: 15px 16px; border-radius: 18px; }
.overlay.ng-result-overlay .dialog-actions { margin-top: 13px; }

/* 完成后收起统计与模式控件，把空间让给像素图案 */
.g-nonogram.solved-view .ng-stats,
.g-nonogram.solved-view .ng-ctrl { display: none; }
.g-nonogram.solved-view .ng-board-wrap {
  padding-bottom: 4px;
  justify-content: flex-start;
  padding-top: 6px;
}
.g-nonogram.solved-view .ng-board { margin: 0 auto; }
