/* ===== 數字填填看 (Kakuro) — style ===== */

.kakuro-wrap {
  max-width: 420px;
  margin: 0 auto;
  overflow-x: auto;
}

/* --- 格子 --- */
.kakuro-grid {
  display: inline-grid;
  gap: 2px;
  background: var(--border);
  border-radius: 10px;
  padding: 2px;
  margin: 0 auto;
}

.kk-cell {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 4px;
  position: relative;
  user-select: none;
}

/* 黑格（空白／提示格） */
.kk-cell.black {
  background: var(--text-primary);
  color: transparent;
}

/* 提示格 — 斜線分區 */
.kk-cell.clue {
  background: var(--text-primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  position: relative;
}
.kk-cell.clue::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(to bottom right, transparent 49%, rgba(255,255,255,0.3) 49%, rgba(255,255,255,0.3) 51%, transparent 51%);
  pointer-events: none;
}
.clue-down {
  position: absolute;
  bottom: 3px;
  left: 4px;
  font-size: 0.72rem;
  color: #7ecbff;
}
.clue-right {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 0.72rem;
  color: #ffe066;
}

/* 白格（可填數字） */
.kk-cell.white {
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
}
.kk-cell.white:hover {
  background: var(--bg-secondary);
}
.kk-cell.white.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.25);
  background: #e6f4ff;
}
[data-theme="dark"] .kk-cell.white.selected {
  background: #1a2a3c;
}
.kk-cell.white.error {
  color: #ff4d4f;
  background: #fff1f0;
}
[data-theme="dark"] .kk-cell.white.error {
  background: #3a1a1a;
}
.kk-cell.white.correct {
  color: #52c41a;
  background: #f6ffed;
}
[data-theme="dark"] .kk-cell.white.correct {
  background: #1a3a1a;
}

/* --- 數字面板 --- */
.kakuro-numpad {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.numpad-btn {
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
}
.numpad-btn:hover {
  border-color: var(--primary);
  transform: scale(1.08);
}
.numpad-btn:active {
  transform: scale(0.95);
}
.numpad-clear {
  background: #ff4d4f;
  color: #fff;
  border-color: #ff4d4f;
}

/* --- 新紀錄 --- */
.new-record-text {
  font-size: 1.3rem;
  color: #fa8c16;
  font-weight: 700;
  animation: pop-in 0.5s ease;
}
@keyframes pop-in {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* --- RWD --- */
@media (max-width: 400px) {
  .kk-cell {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
  .clue-down, .clue-right { font-size: 0.65rem; }
  .numpad-btn { width: 38px; height: 38px; font-size: 1.05rem; }
}
