/* 노노그램(피크로스) — 2026-09-19 전면 재작성
   ★판은 어느 테마에서도 같은 대비로 보이도록 자체 팔레트를 쓴다.
     예전 판은 칸 #2f3640 · 배경 #0f1418 · 선 #485460 이라 어두운 데 어두운 게 겹쳐
     빈 칸과 배경이 거의 구분되지 않았다(스크린샷 확인). 선과 칸을 확실히 띄운다★ */
#ng {
  --ng-bg:     #17202a;
  --ng-board:  #0d141b;
  --ng-cell:   #33465c;   /* 빈 칸 — 배경보다 확실히 밝게 */
  --ng-line:   #56708c;   /* 칸 경계 */
  --ng-bold:   #8fb3d9;   /* 5칸 묶음 경계 */
  --ng-fill:   #f4f7fb;   /* 칠한 칸 */
  --ng-cross:  #7f8c9b;
  --ng-ink:    #eaf1f8;
  --ng-dim:    #9fb0c2;
  --ng-good:   #2ed573;
  --ng-bad:    #ff5b6b;
  --ng-accent: #4aa3ff;
  position: relative;
  max-width: 720px;
  margin: 16px auto 0;
  padding: 16px 14px 18px;
  border-radius: 18px;
  background: var(--ng-bg);
  color: var(--ng-ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Noto Sans KR', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#ng *, #ng *::before, #ng *::after { box-sizing: border-box; }
#ng [hidden] { display: none !important; }

/* ── 상단 HUD ───────────────────────────────────────── */
#ng .ng-hud {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center; margin-bottom: 10px;
}
#ng .ng-hud > div {
  flex: 1 1 auto; min-width: 72px; text-align: center;
  background: rgba(255, 255, 255, .07);
  border-radius: 10px; padding: 6px 8px;
  font-size: 12px; font-weight: 700; color: var(--ng-dim);
  line-height: 1.35;
}
#ng .ng-hud b { display: block; font-size: 15px; color: var(--ng-ink); font-variant-numeric: tabular-nums; }
#ng .ng-hud b.t { color: #74b9ff; }
#ng .ng-hud b.s { color: var(--ng-good); }
#ng #ng-lives { letter-spacing: 1px; color: var(--ng-bad); font-size: 14px; }
#ng #ng-lives .off { opacity: .22; }

/* 진행 막대 — 남은 칸이 눈에 보이게 */
#ng .ng-prog { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; margin-bottom: 12px; }
#ng .ng-prog i { display: block; height: 100%; width: 0; border-radius: 3px;
  background: linear-gradient(90deg, var(--ng-accent), var(--ng-good)); transition: width .25s ease; }

/* ── 보드 ───────────────────────────────────────────── */
#ng .ng-wrap {
  background: var(--ng-board);
  border-radius: 12px;
  padding: 10px;
  min-height: 240px;
  display: flex; align-items: center; justify-content: center;
}
#ng .ng-board {
  display: grid;
  /* --cell / --hw / --hh 는 JS 가 컨테이너 폭에서 계산해 넣는다 */
  grid-template-columns: var(--hw) repeat(var(--n), var(--cell));
  grid-template-rows: var(--hh) repeat(var(--n), var(--cell));
  /* ★드래그 칠하기를 위해 필수 — 없으면 터치가 페이지 스크롤로 먹힌다★ */
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
#ng .ng-corner { background: transparent; }

#ng .ng-ch, #ng .ng-rh {
  display: flex; color: var(--ng-dim);
  font-weight: 800; line-height: 1.15;
  font-size: var(--hint-fs);
  font-variant-numeric: tabular-nums;
}
#ng .ng-ch { flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 4px; gap: 1px; }
#ng .ng-rh { flex-direction: row; align-items: center; justify-content: flex-end; padding-right: 6px; gap: .38em; }
#ng .ng-ch.done, #ng .ng-rh.done { color: var(--ng-good); opacity: .55; }

#ng .ng-c {
  background: var(--ng-cell);
  border: 1px solid var(--ng-line);
  cursor: pointer;
  position: relative;
}
#ng .ng-c.gl { border-left-color: var(--ng-bold); }
#ng .ng-c.gt { border-top-color: var(--ng-bold); }
#ng .ng-c.fill { background: var(--ng-fill); border-color: var(--ng-fill); }
#ng .ng-c.cross::after {
  content: ''; position: absolute; inset: 22%;
  background:
    linear-gradient(45deg, transparent 43%, var(--ng-cross) 43%, var(--ng-cross) 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, var(--ng-cross) 43%, var(--ng-cross) 57%, transparent 57%);
}
#ng .ng-c.bad { background: var(--ng-bad); border-color: var(--ng-bad); animation: ng-shake .28s; }
@keyframes ng-shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-2px); }
  70% { transform: translateX(2px); }
}
@media (prefers-reduced-motion: reduce) {
  #ng .ng-c.bad { animation: none; }
  #ng .ng-prog i { transition: none; }
}

/* ── 조작 ───────────────────────────────────────────── */
#ng .ng-tools { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
#ng .ng-btn {
  appearance: none; border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .08); color: var(--ng-ink);
  font: inherit; font-size: 14px; font-weight: 800;
  padding: 11px 16px; min-height: 44px; border-radius: 12px; cursor: pointer;
  touch-action: manipulation;
}
#ng .ng-btn:disabled { opacity: .4; cursor: default; }
#ng .ng-btn.primary {
  background: linear-gradient(135deg, #0984e3, #4aa3ff);
  border-color: transparent; color: #fff; padding: 13px 26px; font-size: 15px;
}
/* 모드 버튼은 현재 상태가 한눈에 보이게 색을 바꾼다 */
#ng #ng-mode { min-width: 150px; }
#ng #ng-mode[data-mode="fill"] { background: #e9eef5; color: #16202b; border-color: #e9eef5; }
#ng #ng-mode[data-mode="cross"] { background: #4b5b6d; color: #fff; border-color: #4b5b6d; }
#ng .ng-tip { text-align: center; color: var(--ng-dim); font-size: 12px; margin: 10px 0 0; line-height: 1.6; word-break: keep-all; }

/* ── 오버레이 ───────────────────────────────────────── */
/* ★예전에는 #ng-display 가 overflow:hidden 인데 시작 전 높이가 작아
     오버레이 제목과 시작 버튼이 위아래로 잘려 나갔다. inset:0 + overflow:auto 로 절대 안 잘리게★ */
#ng .ng-ov {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(13, 20, 27, .94);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  padding: 18px; overflow: auto;
}
#ng .ng-ov[hidden] { display: none !important; }
#ng .ng-ov-box {
  background: #223142; border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 16px; padding: 24px 20px; text-align: center;
  width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
#ng .ng-ov-box h2 { margin: 0 0 10px; font-size: 19px; font-weight: 900; color: var(--ng-ink); }
#ng .ng-ov-box p { margin: 0 0 16px; font-size: 13.5px; line-height: 1.7; color: var(--ng-dim); word-break: keep-all; }
#ng .ng-ov-score { font-size: 30px; font-weight: 900; color: #ffd32a; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
#ng .ng-ov-sub { font-size: 12.5px; color: var(--ng-dim); margin-bottom: 16px; }

/* 스테이지 클리어 토스트 */
#ng .ng-toast {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 25; pointer-events: none;
  background: rgba(13, 20, 27, .92); border: 1px solid var(--ng-good);
  color: var(--ng-good); font-weight: 900; font-size: 18px;
  padding: 14px 24px; border-radius: 14px; white-space: nowrap;
}

/* ── 규칙 안내 ──────────────────────────────────────── */
/* ★전역 .answer_shadow 는 가운데 정렬·상단 여백 0·font-size 1.1em 이라 그대로 두면
     글이 가운데로 몰리고 게임 박스에 딱 붙고 혼자 커 보인다(CLAUDE.md 규격)★ */
.ng-guide { text-align: left; line-height: 1.7; margin-top: 18px; }
.ng-guide h3 { font-size: 1rem; font-weight: 800; margin: 0 0 8px; }
.ng-guide p { font-size: .9rem; margin: 0 0 10px; word-break: keep-all; }
.ng-guide small { display: block; font-size: .8rem; color: #888; line-height: 1.65; }

@media (max-width: 480px) {
  #ng { padding: 13px 10px 16px; border-radius: 15px; }
  #ng .ng-wrap { padding: 8px; }
  #ng .ng-hud > div { min-width: 64px; font-size: 11px; }
  #ng .ng-hud b { font-size: 14px; }
  /* ★버튼 3개가 한 줄에 들어가게 — 기본 크기로는 360px 화면에서 '초기화'가 두 번째 줄로 밀린다★
     터치 목표 높이 44px 는 그대로 둔다. */
  #ng .ng-tools { gap: 6px; }
  #ng .ng-btn { padding: 10px 11px; font-size: 13px; }
  #ng #ng-mode { min-width: 108px; }
  #ng .ng-tip { font-size: 11.5px; }
}
