/* 密码推理专属样式（参考数独暖色调风格） */

#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto;
  grid-template-areas:
    "sidebar play";
  gap: 20px;
  align-items: start;
  width: 100%;
  max-width: 820px;
}

#sidebar {
  grid-area: sidebar;
  background: var(--panel);
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.actions { display: flex; flex-direction: column; gap: 8px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row .btn { padding: 10px 8px; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.stat-value.muted { color: var(--primary); opacity: 0.4; }

/* 主区：上线索 / 下输入+键盘+排除面板 */
#play-area {
  grid-area: play;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 14px;
  padding: 20px;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  width: 100%;
  align-content: start;
}

/* 线索列表（自适应高度，不滚动） */
.clues {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 500px;
  justify-self: center;
}

.clue-row {
  display: grid;
  grid-template-columns: 110px 70px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.clue-code {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #3d342c;
}

.clue-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1.5px solid var(--border);
}

.dot.exact {
  background: #c75b4a;
  border-color: #c75b4a;
}

.dot.partial {
  background: #fdfaf1;
  border-color: #d4a040;
}

.clue-feedback {
  font-size: 14px;
  color: #8a7d66;
}

/* 提示消息 */
.hint-msg {
  justify-self: center;
  padding: 10px 20px;
  background: #fff4d6;
  color: #8a5a00;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.guess.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* 答案输入区：格子固定大小，不受位数影响 */
.guess {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.guess-cell {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  background: var(--bg);
  border: 2px solid #d9cfb8;
  border-radius: 12px;
  color: #3d6594;
  transition: border-color 0.15s, transform 0.08s;
  cursor: pointer;
}

.guess-cell.filled {
  border-color: #3d6594;
  background: #eaf0ff;
}

.cell-value {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-weight: 700;
  color: #2b4a70;
}

.cell-notes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  width: 100%; height: 100%;
  padding: 3px;
  font-size: 11px;
  color: #8a7d66;
  gap: 1px;
}
.cell-notes .note { display: flex; align-items: center; justify-content: center; }

.guess-cell.cursor {
  border-color: #3d6594;
  box-shadow: 0 0 0 3px rgba(61, 101, 148, 0.25);
}

.guess-cell.answer {
  background: #ffe4e4;
  border-color: #c75b4a;
  color: #c75b4a;
}

/* 数字键盘（数独风格：暖色调扁平按钮，2行×6列） */
.numpad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 420px;
  justify-self: center;
}

.num-btn {
  padding: 14px 0;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: #3d342c;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
}

@media (hover: hover) {
  .num-btn:hover { background: #efe6cf; }
}

.num-btn:active { transform: translateY(1px); }
.num-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.num-btn.erase {
  color: #c75b4a;
  font-size: 20px;
}

.num-btn.submit {
  background: #51cf66;
  color: white;
  font-size: 22px;
  font-weight: 700;
}

.num-btn.submit:hover { background: #40c057; }
.num-btn.submit:disabled { background: #b2f2bb; }

/* 排除面板 */
.marks-section {
  width: 100%;
  max-width: 420px;
  justify-self: center;
  padding-top: 10px;
  border-top: 1px dashed #d9cfb8;
}

.marks-label {
  font-size: 13px;
  color: #8a7d66;
  margin-bottom: 8px;
  text-align: center;
}

.marks {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}

.mark-btn {
  position: relative;
  aspect-ratio: 1 / 1;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #3d342c;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s;
}

@media (hover: hover) {
  .mark-btn:hover { background: #efe6cf; }
}

.mark-btn:active { transform: translateY(1px); }
.mark-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.mark-btn.mark-in {
  background: #d3f9d8;
  border-color: #51cf66;
  color: #2b8a3e;
}

.mark-btn.mark-out {
  background: #ffe4e4;
  border-color: #ff8787;
  color: #c92a2a;
  text-decoration: line-through;
}

.mark-tag {
  position: absolute;
  top: -3px;
  right: -3px;
  font-size: 10px;
  line-height: 1;
}

/* 结算弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--panel);
  border-radius: 20px;
  padding: 32px 36px;
  text-align: center;
  min-width: 280px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  animation: popIn 0.25s ease;
}

.modal-content h2 { margin: 0 0 16px; }
.modal-content p { margin: 8px 0; color: #8a7d66; }
.modal-content .record { font-weight: 700; color: #d4a040; }
.modal-content .btn { margin-top: 16px; }

/* 自定义密码弹窗 */
.custom-modal { padding: 0; overflow: hidden; min-width: 320px; }
.custom-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f7ecd6 0%, #efdfc2 100%);
  border-bottom: 1px solid #e8dfce;
}
.custom-modal-header h2 {
  margin: 0; font-size: 17px; color: #5a4d38;
}
.custom-close {
  background: none; border: none; font-size: 16px; color: #8a7d66;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: background 0.15s;
}
.custom-close:hover { background: rgba(0,0,0,0.06); color: #5a4d38; }
.custom-modal-body {
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.custom-length-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.custom-length-label {
  font-size: 14px; color: #8a7d66; font-weight: 600;
}
.custom-length-btns {
  display: flex; gap: 4px;
  background: #f2e8d4; padding: 3px; border-radius: 10px;
}
.len-btn {
  border: none; background: transparent; color: #8a7d66;
  padding: 6px 14px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit;
  transition: all 0.15s;
}
.len-btn:hover { color: #5a4d38; }
.len-btn.active {
  background: #fff; color: #3d6594;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.custom-repeat-row {
  display: flex; justify-content: center;
}
.custom-check {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; color: #8a7d66; cursor: pointer;
  user-select: none;
}
.custom-check input { cursor: pointer; }
.custom-cells {
  display: flex; gap: 10px; justify-content: center;
}
.custom-cell {
  width: 52px; height: 58px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; color: #5a4d38;
  background: #fff9ef;
  border: 2px solid #d8c9ad; border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.custom-cell.filled { border-color: #3d6594; color: #3d6594; }
.custom-cell.cursor {
  border-color: #3d6594;
  box-shadow: 0 0 0 3px rgba(61,101,148,0.18);
}
.custom-cell.empty::before {
  content: '·'; color: #d8c9ad; font-size: 24px;
}
.custom-error { color: #c0453e; font-size: 13px; min-height: 18px; text-align: center; }

/* 隐藏 input：视觉上不可见，但用于唤起移动端软键盘 */
.custom-hidden-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}
.custom-modal-footer {
  padding: 0 20px 20px;
  display: flex; justify-content: center;
}
.btn-lg { padding: 12px 32px; font-size: 15px; min-width: 160px; }

/* 响应式 */
@media (max-width: 640px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "sidebar"
      "play";
  }
  #play-area { min-height: auto; }
  .num-btn { min-height: 44px; padding: 10px 0; }
  .marks { grid-template-columns: repeat(5, 1fr); }
}
