/* 数独练习场 · 样式 */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg1: #e8f6ff;
  --bg2: #d0ecff;
  --ink: #1a3350;
  --accent: #2f7df6;
  --accent-dark: #1d5fd0;
  --warn: #e53935;
  --ok: #2e9e5b;
  --card: #ffffff;
  --line: #b9cfe0;
  --given-bg: #dfe9f2;
}

html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  min-height: 100vh;
}

#app { max-width: 1280px; margin: 0 auto; padding: 18px 20px 40px; }

.screen { animation: fadein .25s ease; }
.hidden { display: none !important; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ---------- 首页 ---------- */
.logo { text-align: center; font-size: 44px; margin: 26px 0 6px; letter-spacing: 2px; }
.subtitle { text-align: center; color: #51708e; font-size: 17px; margin-bottom: 34px; }
.tip { text-align: center; color: #7d97ad; margin-top: 26px; }

.card-row { display: flex; flex-wrap: wrap; gap: 22px; justify-content: center; }

.group-card {
  width: 300px; background: var(--card); border-radius: 20px; padding: 24px 26px;
  box-shadow: 0 6px 18px rgba(30, 80, 140, .12); cursor: pointer;
  border: 3px solid transparent; transition: transform .15s, border-color .15s, box-shadow .15s;
}
.group-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 10px 24px rgba(30,80,140,.18); }
.group-card h3 { font-size: 24px; margin-bottom: 6px; }
.group-card .desc { color: #64809c; font-size: 14px; margin-bottom: 12px; }
.group-card .meta { font-size: 13px; color: #3f6a8f; }
.group-card.disabled { opacity: .55; cursor: not-allowed; }
.group-card.disabled:hover { transform: none; border-color: transparent; }

/* ---------- 轮次页 ---------- */
.page-head { display: flex; align-items: center; gap: 16px; margin: 10px 0 22px; }
.page-head h2 { font-size: 30px; }

.round-card {
  background: var(--card); border-radius: 18px; padding: 20px 24px; margin-bottom: 18px;
  box-shadow: 0 4px 14px rgba(30,80,140,.10); display: flex; gap: 20px; align-items: center;
}
.round-info { flex: 1; min-width: 0; }
.round-info h3 { font-size: 21px; margin-bottom: 4px; }
.round-info .sub { color: #64809c; font-size: 14px; margin-bottom: 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: #eaf3ff; color: #2a5d94; border-radius: 999px; padding: 3px 10px; font-size: 12.5px;
}
.best-badge { color: var(--ok); font-weight: 600; font-size: 13px; margin-top: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 12px; padding: 10px 22px; font-size: 16px; font-weight: 600;
  background: #e3eefb; color: var(--accent-dark); cursor: pointer; transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; color: #51708e; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 倒计时 ---------- */
#screen-count {
  position: fixed; inset: 0; background: rgba(16, 44, 84, .92); z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#count-num {
  color: #fff; font-size: 200px; font-weight: 800; animation: pop 1s ease infinite;
  text-shadow: 0 0 60px rgba(120, 200, 255, .8);
}
#count-tip { color: #bcd9ff; font-size: 22px; margin-top: 10px; }
@keyframes pop {
  0% { transform: scale(2.4); opacity: 0; }
  25% { transform: scale(1.15); opacity: 1; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(.9); opacity: 0; }
}

/* ---------- 答题页 ---------- */
#game-bar {
  position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.94); backdrop-filter: blur(6px);
  border-radius: 14px; padding: 10px 16px; display: flex; align-items: center; gap: 14px;
  box-shadow: 0 3px 12px rgba(30,80,140,.12); margin-bottom: 18px; flex-wrap: wrap;
}
#game-title { font-weight: 700; font-size: 17px; flex: 1; min-width: 120px; }
#clock { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 118px; }
#clock.warn #clock-text { color: var(--warn); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: .45; } }

.mode-toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; color: #51708e; cursor: pointer; user-select: none; }
.mode-toggle input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

#puzzle-area { display: flex; flex-wrap: wrap; gap: 22px; justify-content: center; align-items: flex-start; padding-bottom: 0; }

.puzzle-card {
  background: var(--card); border-radius: 16px; padding: 14px 16px 16px;
  box-shadow: 0 4px 14px rgba(30,80,140,.10); position: relative;
}
.puzzle-card.selected { outline: 3px solid var(--accent); }
.puzzle-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.puzzle-head .pno { font-weight: 800; font-size: 16px; color: var(--accent-dark); }
.puzzle-head .pname { font-size: 14px; color: #51708e; }
.puzzle-head .ppts { font-size: 12.5px; background: #fff3d6; color: #9c6d00; padding: 2px 9px; border-radius: 999px; }
.puzzle-head .pstat { margin-left: auto; font-size: 15px; font-weight: 700; }
.puzzle-head .pstat.ok { color: var(--ok); }
.puzzle-head .pstat.bad { color: var(--warn); }

/* ---------- 盘面 ---------- */
.board-wrap { position: relative; display: inline-block; }
.board {
  display: grid; background: #fff; user-select: none;
  border: 3px solid #33475c; border-radius: 4px;
}
.board.n4 { --cell: 66px; grid-template-columns: repeat(4, var(--cell)); }
.board.n6 { --cell: 54px; grid-template-columns: repeat(6, var(--cell)); }
.board.n9 { --cell: 42px; grid-template-columns: repeat(9, var(--cell)); }
@media (max-width: 720px) {
  .board.n4 { --cell: 52px; } .board.n6 { --cell: 43px; } .board.n9 { --cell: 34px; }
}

.cell {
  width: var(--cell); height: var(--cell); position: relative;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell) * .52); font-weight: 700; color: #2360c4; cursor: pointer;
}
.board.n9 .cell { font-size: calc(var(--cell) * .46); }
/* 末行/末列边线由 JS 按盘面尺寸处理，避免 nth-child 规则误伤非 4 列盘面 */.cell.given { color: #16324e; font-weight: 700; }
.cell.d1 { background: rgba(110, 190, 255, .18); }
.cell.d2 { background: rgba(255, 170, 90, .20); }
.cell.d1.d2 { background: rgba(150, 140, 255, .22); }
.cell.gray { background: #b9bec4; color: #fff; }
.cell.shadow { background: rgba(150, 160, 175, .30); }
.cell.shadow2 { background: rgba(255, 205, 120, .42); }
.cell.dead { cursor: default; }
.cell.same { background: #fff2ae; }
.cell.sel { background: #cfe4ff !important; box-shadow: inset 0 0 0 2.5px var(--accent); z-index: 2; }
.cell.bad { color: var(--warn) !important; background: #ffd9d6 !important; }
.cell .val { pointer-events: none; line-height: 1; }
.cell.bad .val { animation: shake .3s ease; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.notes {
  position: absolute; inset: 2px; display: grid; z-index: 1; pointer-events: none;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
}
.notes span {
  font-size: calc(var(--cell) * .24); color: #7a8aa0; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

svg.overlay { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 3; }

/* ---------- 数字键盘 ---------- */
#numpad-wrap { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; padding: 8px 8px 10px; background: linear-gradient(transparent, rgba(232,246,255,.95) 30%); }
#numpad {
  background: #fff; border-radius: 18px; padding: 10px 12px; display: flex; gap: 8px; align-items: center;
  box-shadow: 0 6px 20px rgba(30,80,140,.18); flex-wrap: wrap; justify-content: center;
}
.key {
  width: 52px; height: 52px; border-radius: 12px; border: none; background: #eaf3ff;
  font-size: 23px; font-weight: 700; color: var(--accent-dark); cursor: pointer; transition: filter .1s, transform .08s;
}
.key:hover { filter: brightness(.95); }
.key:active { transform: scale(.93); }
.key.func { background: #fff1e0; color: #a05e00; font-size: 20px; width: 60px; }
.key.func.on { background: #ffca6e; color: #6d4300; box-shadow: inset 0 0 0 2px #a05e00; }
.key.dim { opacity: .3; pointer-events: none; }

/* ---------- 结果页 ---------- */
.result-card {
  max-width: 640px; margin: 40px auto; background: #fff; border-radius: 22px; padding: 34px 38px;
  box-shadow: 0 10px 30px rgba(30,80,140,.16); text-align: center;
}
.result-card h2 { font-size: 26px; margin-bottom: 18px; }
#result-score { font-size: 64px; font-weight: 800; margin: 6px 0; }
#result-score .good { color: var(--ok); }
#result-score .poor { color: var(--warn); }
#result-time { color: #51708e; font-size: 16px; margin-bottom: 6px; }
#result-best { color: var(--ok); font-weight: 700; margin-bottom: 16px; min-height: 22px; }
#result-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0 24px; }
.rchip { border-radius: 10px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; background: #f1f5f9; }
.rchip.ok { background: #d9f3e3; color: #1c7a44; }
.rchip.bad { background: #ffddda; color: #b3261e; }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- 加减/比例 cage 配色（同框同色，相邻框交替） ---------- */
.cell.cageA { background: #e3f0fd; }
.cell.cageB { background: #fdf3df; }
.cell.cageA.given { }
.cell.cageB.given { }

/* ---------- 导航条与进度 ---------- */
#progress { font-size: 14.5px; color: #33618e; font-weight: 600; white-space: nowrap; }
#sub-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 6px 0 14px;
}
#nav-pos { font-size: 15px; font-weight: 700; color: #33618e; min-width: 130px; text-align: center; }
.puzzle-card.card-off { display: none; }
.puzzle-card.solo { min-width: min-content; }
.puzzle-card.solo .board.n4 { --cell: 82px; }
.puzzle-card.solo .board.n6 { --cell: 68px; }
.puzzle-card.solo .board.n9 { --cell: 54px; }
@media (max-width: 720px) {
  .puzzle-card.solo .board.n4 { --cell: 64px; }
  .puzzle-card.solo .board.n6 { --cell: 52px; }
  .puzzle-card.solo .board.n9 { --cell: 40px; }
}
#btn-view { font-size: 14px; padding: 8px 14px; }

/* ---------- 自由练习 ---------- */
.group-card.special { border: 2px dashed #9cc4ec; background: #f4faff; }
.free-panel { max-width: 620px; margin: 10px auto; background: #fff; border-radius: 20px; padding: 28px 32px; box-shadow: 0 6px 18px rgba(30,80,140,.12); }
.opt-row { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.opt-label { width: 90px; font-weight: 700; color: #33618e; }
.opt-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btn.opt { background: #eef4fb; color: #40678e; padding: 9px 20px; }
.btn.opt.on { background: var(--accent); color: #fff; }
.free-go { text-align: center; margin-top: 26px; }
.btn.big { font-size: 19px; padding: 13px 34px; }
#free-status { margin-top: 12px; color: #7d97ad; font-size: 14px; min-height: 20px; }

/* ---------- 导入弹窗 ---------- */
#modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,40,75,.55); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#modal {
  background: #fff; border-radius: 18px; padding: 24px 28px; max-width: 640px; width: 100%;
  box-shadow: 0 16px 50px rgba(0,20,50,.35); max-height: 88vh; overflow: auto;
}
#modal h3 { margin-bottom: 8px; }
.modal-tip { font-size: 13.5px; color: #51708e; margin-bottom: 8px; }
.modal-code {
  background: #f2f6fa; border-radius: 10px; padding: 10px 14px; font-size: 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace; overflow: auto; margin-bottom: 10px;
}
#import-text {
  width: 100%; height: 140px; border: 2px solid #cfe0ef; border-radius: 10px;
  padding: 10px; font-size: 13px; font-family: Menlo, Consolas, monospace; resize: vertical;
}
#import-text:focus { outline: none; border-color: var(--accent); }
#import-err { color: var(--warn); font-size: 13px; min-height: 18px; margin: 6px 0; white-space: pre-wrap; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

@media (max-width: 720px) {
  #app { padding: 10px 8px 40px; }
  .logo { font-size: 32px; }
  #count-num { font-size: 130px; }
  .key { width: 44px; height: 42px; font-size: 18px; }
  .key.func { width: 52px; }
}

/* —— 做题反馈 toast（练习模式做完一题自动弹出）—— */
#toast {
  position: fixed;
  left: 50%;
  top: 72px;
  transform: translateX(-50%) translateY(-8px);
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 6px 20px rgba(20, 40, 70, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 90;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.ok { background: #2e9e5b; }
#toast.bad { background: #d64541; }

/* ---------- 模拟考试卷头 / 考生信息 ---------- */
#exam-head {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  flex-wrap: wrap;
  margin: 0 14px; padding: 7px 14px;
  border: 2px solid #33475c; border-radius: 8px;
  background: #f4f7fa; color: #33475c;
  font-size: 14px; letter-spacing: 1px;
}
#exam-head b { color: #1e3040; font-weight: 800; }
#exam-head .ex-judge i {
  display: inline-block; width: 44px; height: 12px;
  border-bottom: 1.5px solid #6c8199; vertical-align: baseline;
}
#exam-card {
  background: #fff; border-radius: 18px; padding: 22px 26px; width: 100%; max-width: 360px;
  box-shadow: 0 16px 50px rgba(0,20,50,.35);
}
#exam-card h3 { margin-bottom: 6px; }
.exam-field { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.exam-field label { width: 66px; text-align: right; color: #41586e; font-size: 14px; }
.exam-field input {
  flex: 1; padding: 8px 10px; border: 1.5px solid #b8c8d8; border-radius: 8px;
  font-size: 15px; outline: none;
}
.exam-field input:focus { border-color: #3f8ef7; }
#result-exam {
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
  margin: 4px 0 10px; padding: 7px 12px;
  border: 1.5px dashed #8aa0b5; border-radius: 8px;
  color: #41586e; font-size: 14px;
}
#result-exam b { color: #1e3040; }
#result-exam i { display: inline-block; width: 40px; border-bottom: 1.5px solid #6c8199; }
#result-hist { margin: 8px 0 12px; font-size: 13px; color: #6c8199; text-align: left; }
#result-hist > b { display: block; margin-bottom: 4px; color: #41586e; }
#result-hist .hist-row { padding: 2px 0; border-bottom: 1px dashed #dde7ef; }
#result-hist .hist-row.newest { color: #2e9e5b; font-weight: 700; }

/* ===== 体验增强 v1.0.3：peer 高亮 / 模式徽章 / 快捷键提示 ===== */
.cell.peer { background: #eef4fb; }
.mode-bar { display: flex; justify-content: flex-end; padding: 0 4px 10px; }
.mode-badge { font-size: 13px; font-weight: 700; color: #51708e; background: #eef4fb; border: 1px solid #d5e3f0; border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
#kbd-hints { text-align: center; font-size: 11px; color: #8ba3b8; padding: 2px 0 56px; }
@media (max-width: 760px) { #kbd-hints { display: none; } }

/* ===== 自定义确认弹窗 v1.0.7（替代浏览器原生 confirm） ===== */
#confirm-card { background: #fff; border-radius: 18px; padding: 22px 26px; width: 100%; max-width: 360px; box-shadow: 0 16px 50px rgba(0,20,50,.35); }
#confirm-card p { color: #41586e; font-size: 15px; line-height: 1.6; margin: 6px 0 16px; }

/* ===== 题目规则面板 v1.1.0 ===== */
.rule-box { background: #f4f8fc; border: 1px solid #d9e6f2; border-radius: 10px; padding: 6px 10px; margin: -2px 0 6px; font-size: 12.5px; line-height: 1.55; color: #41586e; max-width: 100%; }
.rule-box b { color: #27415c; margin-right: 6px; }

/* ===== v1.1.2：单屏无滚动 + 底部操作栏统一 ===== */
@media (max-height: 920px) { --cell-t9: 46px; --cell-t6: 58px; --cell-t4: 70px; }
@media (max-height: 880px) {
  .puzzle-card.solo .board.n4 { --cell: 70px; }
  .puzzle-card.solo .board.n6 { --cell: 56px; }
  .puzzle-card.solo .board.n9 { --cell: 44px; }
}
@media (max-height: 760px) {
  .puzzle-card.solo .board.n4 { --cell: 62px; }
  .puzzle-card.solo .board.n6 { --cell: 48px; }
  .puzzle-card.solo .board.n9 { --cell: 38px; }
}
#pad-actions { display: flex; align-items: center; gap: 8px; margin-right: 14px; }
#pad-actions button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 58px; height: 56px; padding: 4px 10px;
  background: #fff; border: 1px solid #d5e3f0; border-radius: 12px;
  box-shadow: 0 2px 6px rgba(30,60,100,.10); cursor: pointer; user-select: none;
}
#pad-actions button:active { transform: translateY(1px); }
#pad-actions .ic { font-size: 20px; line-height: 1.1; color: #27415c; }
#pad-actions .tx { font-size: 11px; color: #51708e; margin-top: 2px; white-space: nowrap; }

/* ===== v1.1.4 练习提示开关条 ===== */
#hint-bar { display:flex; align-items:center; gap:14px; padding:5px 14px; font-size:13px; color:#51708e; background:#f6fafd; border-bottom:1px solid #e3edf6; flex-wrap:wrap; }
#hint-bar label { display:flex; align-items:center; gap:5px; cursor:pointer; user-select:none; }
#hint-bar input { width:15px; height:15px; accent-color: var(--accent); cursor:pointer; }
#hint-bar .hb-title { font-weight:700; color:#41586e; }

/* ===== v1.1.7 暂停遮罩 + 首页继续卡 ===== */
#pause-mask { position: fixed; inset: 0; background: rgba(13,30,52,.72); display: flex; align-items: center; justify-content: center; z-index: 200; }
.pause-card { background: #fff; border-radius: 18px; padding: 28px 40px; text-align: center; box-shadow: 0 16px 50px rgba(0,20,50,.35); }
.pause-card h2 { margin: 0 0 6px; color: #27415c; }
.pause-card p { margin: 0 0 16px; color: #51708e; font-size: 14px; }
.resume-card { display: block; width: 100%; text-align: left; background: #eaf4ff; border: 2px solid #7fb0e8; border-radius: 14px; padding: 12px 16px; margin-bottom: 12px; font-size: 14px; color: #27415c; cursor: pointer; }
.resume-card b { color: #1d5aad; }
.resume-card:hover { background: #dcebfd; }
