/* 数独本体样式 — 颜色全部走 chrome.css 主题 token（浅色默认，深色随 data-theme） */

.wrap {
  width: min(92vw, 480px);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 56px) 0 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.top { display: flex; align-items: center; gap: 12px; }
.top h1 { font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.back { color: var(--fg-secondary); font-size: 14px; white-space: nowrap; }
.back:hover { color: var(--fg); }
.timer {
  margin-left: auto; color: var(--accent); font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

.pills { display: flex; gap: 8px; }
.pills button {
  flex: 1; background: var(--bg-raised); color: var(--fg-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 7px 0; font-size: 14px; font-family: inherit; cursor: pointer;
  transition: color .15s, border-color .15s;
  touch-action: manipulation;
}
.pills button.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.pills button:hover { color: var(--fg); }

.board-wrap { position: relative; }
.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1; width: 100%;
  background: var(--bg-panel);
  border: 2px solid color-mix(in srgb, var(--fg) 35%, transparent);
  border-radius: var(--radius-lg);
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.cell {
  display: grid; place-items: center;
  font-size: clamp(18px, 4.6vw, 30px);
  font-weight: 600;
  color: var(--accent); /* 玩家数字 */
  border-right: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
  cursor: pointer;
}
.cell:nth-child(9n) { border-right: none; }
.cell:nth-child(n+73) { border-bottom: none; }
.cell.br { border-right: 2px solid color-mix(in srgb, var(--fg) 28%, transparent); }
.cell.bb { border-bottom: 2px solid color-mix(in srgb, var(--fg) 28%, transparent); }
.cell.given { color: var(--fg); }
.cell.peer { background: color-mix(in srgb, var(--fg) 4%, transparent); }
.cell.same { color: var(--accent); background: var(--accent-soft); }
.cell.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.cell.conflict { color: #e5484d; background: rgba(229, 72, 77, .12); }
.cell.conflict.selected { box-shadow: inset 0 0 0 2px #e5484d; }
.notes {
  display: grid; grid-template-columns: repeat(3, 1fr);
  width: 100%; height: 100%; padding: 6%;
}
.notes span {
  display: grid; place-items: center;
  font-size: clamp(7px, 1.9vw, 11px); font-weight: 500;
  color: var(--fg-muted); line-height: 1;
}

.overlay {
  position: absolute; inset: 0; border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
}
.overlay.hidden { display: none; }
.win-title { font-size: 26px; font-weight: 800; }
.win-sub { color: var(--fg-secondary); }

.toolbar { display: flex; gap: 8px; }
.gbtn {
  flex: 1; background: var(--bg-raised); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 0; font-size: 14px; font-family: inherit; cursor: pointer;
  transition: border-color .15s, color .15s;
  touch-action: manipulation;
}
.gbtn:hover { border-color: var(--accent); }
.gbtn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.gbtn.primary {
  flex: none; padding: 10px 22px; color: #fff; border: none;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  font-weight: 600;
}

.numpad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.numpad button {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--fg); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 52px; gap: 2px; cursor: pointer;
  transition: border-color .15s;
  touch-action: manipulation;
}
.numpad button:hover { border-color: var(--accent); }
.numpad button .d { font-size: 18px; font-weight: 700; line-height: 1; }
.numpad button .left { font-size: 10px; color: var(--fg-muted); line-height: 1; }
.numpad button.done .d { color: var(--fg-muted); }

.hint { color: var(--fg-muted); font-size: 12px; text-align: center; line-height: 1.7; }

/* --- AI 提示 / 代打(配色纪律同 2048:品牌动作渐变蓝,运行态反转墨色) --- */

.ai-bar { display: flex; gap: 8px; }
.ai-run {
  flex: 1; color: #fff; border: none; border-radius: var(--radius-md);
  padding: 10px 0; font-size: 14px; font-family: inherit; font-weight: 600;
  cursor: pointer; touch-action: manipulation;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  transition: filter .15s;
}
.ai-run:hover { filter: brightness(1.12); }
.ai-run.running { background: var(--fg); color: var(--bg); } /* 反转时文字跟着翻色,防暗色主题白底白字 */
.ai-run.running:hover { filter: brightness(1.3); }

.ai-banner {
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px; line-height: 1.9; color: var(--fg-secondary);
}
.ai-banner .tag {
  display: inline-block; margin-right: 8px; padding: 1px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  white-space: nowrap;
}
.ai-banner.err {
  border-color: rgba(229, 72, 77, .45);
  background: rgba(229, 72, 77, .07);
  color: #e5484d;
}
.ai-banner.err .tag {
  color: #e5484d; background: rgba(229, 72, 77, .1);
  border-color: rgba(229, 72, 77, .4);
}
.ai-banner.hidden { display: none; }

/* 目标格:呼吸高亮 + 幽灵数字预览(要填哪、填什么,一眼可见) */
.cell.hint-target {
  background: var(--accent-soft);
  animation: hintPulse 1.2s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { box-shadow: inset 0 0 0 2px var(--accent); }
  50% { box-shadow: inset 0 0 0 4px var(--accent); }
}
.cell.hint-target .ghost { color: var(--fg-muted); font-weight: 500; opacity: .8; }
/* 理由格:橙色 = 排除依据(已出现的数字);红 = 矛盾格 */
.cell.hint-why {
  background: rgba(240, 158, 40, .2);
  box-shadow: inset 0 0 0 1.5px rgba(240, 158, 40, .5);
}
.cell.hint-bad {
  background: rgba(229, 72, 77, .16);
  box-shadow: inset 0 0 0 1.5px rgba(229, 72, 77, .5);
}
/* AI 落子瞬间的小弹跳 */
.cell.pop { animation: pop .45s ease; }
@keyframes pop {
  0% { transform: scale(.5); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* --- 导入自定义题(全屏遮罩卡片;三档反馈:绿=唯一解 橙=多解放行 红=拒绝) --- */

.imodal {
  position: fixed; inset: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.imodal.hidden { display: none; }

.imodal-card {
  width: min(92vw, 460px);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .18);
}
.imodal-card h2 { font-size: 18px; font-weight: 700; }
.imodal-tip { font-size: 12.5px; line-height: 1.7; color: var(--fg-muted); }

#importText {
  width: 100%; box-sizing: border-box; resize: vertical;
  background: var(--bg-raised); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 12px; font-family: ui-monospace, monospace;
  font-size: 12px; line-height: 1.6; letter-spacing: .5px;
}
#importText:focus { outline: none; border-color: var(--accent); }

.imodal-msg {
  min-height: 18px; font-size: 13px; line-height: 1.6;
}
.imodal-msg.ok { color: var(--accent); }
.imodal-msg.warn { color: #f09e28; }
.imodal-msg.err { color: #e5484d; }

.imodal-btns { display: flex; gap: 8px; }
.imodal-btns .gbtn { flex: none; padding: 10px 16px; }
.imodal-gap { flex: 1; }
.imodal-btns #importExport { margin-right: auto; }
