/* 数独小游戏 · 移动优先，深色主题 */
:root {
  --bg: #0f1420;
  --bg-2: #151c2b;
  --panel: #1b2434;
  --line: #26304330;
  --line-strong: #2f3b52;
  --text: #e8eef8;
  --dim: #8892a6;
  --accent: #f5b942;
  --accent-2: #ffd479;
  --good: #4ade80;
  --bad: #f87171;
  --cell: #1b2434;
  --cell-fixed: #121a27;
  --cell-sel: #2a3a58;
  --cell-peer: #1f2a3d;
  --cell-same: #26344c;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: radial-gradient(120% 80% at 50% 0%, #182338 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
  user-select: none;
}

.screen {
  display: none;
  flex-direction: column;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100%;
  padding: max(16px, env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
}
.screen.is-active { display: flex; }

/* ---------- 首页 ---------- */
.home__head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand__mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), #e08b19);
  color: #22170a; font-weight: 800; font-size: 22px;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px #f5b94233;
}
.brand h1 { font-size: 21px; letter-spacing: .04em; }
.brand p { color: var(--dim); font-size: 12px; }
.streak {
  background: #f5b9421a; border: 1px solid #f5b94240; color: var(--accent-2);
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.streak__flame { margin-right: 2px; }

.modes { display: flex; flex-direction: column; gap: 12px; }
.mode {
  position: relative; text-align: left; cursor: pointer;
  background: linear-gradient(160deg, var(--panel), #161e2c);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 16px 18px; color: inherit; font: inherit;
  transition: transform .12s ease, border-color .12s ease;
}
.mode:active { transform: scale(.985); border-color: var(--accent); }
.mode__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mode__tag {
  font-size: 11px; letter-spacing: .08em; padding: 2px 8px; border-radius: 6px;
  background: #ffffff0f; color: var(--dim);
}
.mode--daily .mode__tag { background: #f5b94226; color: var(--accent-2); }
.mode--blitz .mode__tag { background: #f8717126; color: #ffa3a3; }
.mode h2 { font-size: 17px; margin-bottom: 3px; }
.mode p { color: var(--dim); font-size: 12.5px; }
.mode__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #f5b94226; }
.mode--daily.is-done .mode__dot { background: var(--good); box-shadow: 0 0 0 4px #4ade8026; }

.levels { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong); background: #0e1522; color: var(--dim);
  border-radius: 9px; padding: 7px 11px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
}
.chip b { color: var(--text); font-weight: 600; }
.chip:active { border-color: var(--accent); }

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-top: 18px;
}
.stat { background: #131a28; border: 1px solid #223049; border-radius: 11px; padding: 10px 8px; text-align: center; }
.stat b { display: block; font-size: 17px; }
.stat span { color: var(--dim); font-size: 11px; }

.home__foot {
  margin-top: auto; padding-top: 18px; display: flex; justify-content: space-between;
  color: #5c677c; font-size: 11.5px;
}
.link { background: none; border: 0; color: #6f7c93; font-size: 11.5px; cursor: pointer; text-decoration: underline; }

/* ---------- 游戏页 ---------- */
.game__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: #131a28; color: var(--text); font-size: 16px; cursor: pointer;
  display: grid; place-items: center; line-height: 1;
}
.icon-btn:active { background: #1d2739; }
.game__meta { flex: 1; min-width: 0; }
.game__title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game__sub { color: var(--dim); font-size: 11.5px; }
.game__timer { font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; color: var(--accent-2); }
.game__timer.is-danger { color: var(--bad); }

.progressline { height: 3px; background: #1c2536; border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.progressline i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s ease; }

.board-wrap { position: relative; }
.board {
  display: grid; grid-template-columns: repeat(9, 1fr);
  background: var(--cell-fixed); border: 2px solid #34425c; border-radius: 10px;
  overflow: hidden; aspect-ratio: 1 / 1; touch-action: manipulation;
}
.cell {
  position: relative; display: grid; place-items: center;
  font-size: clamp(17px, 5.2vw, 23px); font-variant-numeric: tabular-nums;
  background: var(--cell); color: var(--accent-2); cursor: pointer;
  border-right: 1px solid #ffffff0a; border-bottom: 1px solid #ffffff0a;
}
.cell.br { border-right: 1px solid #3a4a66; }
.cell.bb { border-bottom: 1px solid #3a4a66; }
.cell.fixed { background: var(--cell-fixed); color: #cbd6e8; font-weight: 600; }
.cell.peer { background: var(--cell-peer); }
.cell.same { background: var(--cell-same); }
.cell.sel { background: var(--cell-sel); box-shadow: inset 0 0 0 2px var(--accent); }
.cell.wrong { color: var(--bad); }
.cell.hinted { animation: pop .35s ease; }
.cell.done { animation: glow .45s ease; }
.cell.shake { animation: shake .3s ease; }
.cell .notes {
  position: absolute; inset: 2px; display: grid;
  grid-template-columns: repeat(3, 1fr); font-size: 8.5px; color: #7d8aa3;
  line-height: 1;
}
.cell .notes span { display: grid; place-items: center; }
.cell .notes span.on { color: #a9c0e0; }

@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }
@keyframes pop { from { transform: scale(.6); opacity: .3 } to { transform: scale(1); opacity: 1 } }
@keyframes glow { from { background: #4ade8040 } to { background: var(--cell) } }

.board-blocker {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: #0b111ccc; backdrop-filter: blur(3px); border-radius: 10px; z-index: 3;
}
.blocker__card { text-align: center; padding: 20px 26px; }
.blocker__card h3 { margin-bottom: 6px; }
.blocker__card p { color: var(--dim); font-size: 12.5px; margin-bottom: 14px; }

.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 10px; }
.tool {
  position: relative; background: #152032; border: 1px solid var(--line-strong);
  color: var(--text); border-radius: 11px; padding: 9px 0 8px; font-size: 11.5px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
}
.tool span { font-size: 15px; line-height: 1; }
.tool:active { border-color: var(--accent); }
.tool.is-on { background: #f5b9421f; border-color: var(--accent); color: var(--accent-2); }
.tool .badge {
  position: absolute; top: 3px; right: 6px; font-style: normal; font-size: 9.5px;
  background: #f5b94226; color: var(--accent-2); border-radius: 6px; padding: 0 4px;
}

.numpad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
.numpad button {
  aspect-ratio: 3 / 4; border: 1px solid var(--line-strong); background: #16203200;
  background: #152032; color: var(--text); border-radius: 9px;
  font-size: clamp(17px, 5vw, 21px); font-weight: 600; cursor: pointer;
  position: relative; font-variant-numeric: tabular-nums;
}
.numpad button:active { background: #22314a; border-color: var(--accent); }
.numpad button.exhausted { color: #3f4a5f; background: #111824; }
.numpad button em {
  position: absolute; bottom: 2px; right: 4px; font-style: normal;
  font-size: 9px; color: #6b778c;
}

.hud { display: flex; justify-content: space-between; color: var(--dim); font-size: 11.5px; margin-top: 10px; }

/* ---------- 结算 ---------- */
.modal {
  position: fixed; inset: 0; background: #060a12e0; backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px; z-index: 10;
}
.modal[hidden] { display: none; }
.modal__card {
  width: 100%; max-width: 340px; background: linear-gradient(165deg, #1c263a, #141b28);
  border: 1px solid var(--line-strong); border-radius: 18px; padding: 24px 20px 18px;
  text-align: center;
}
.stars { font-size: 30px; letter-spacing: 6px; height: 36px; color: #3a4560; }
.stars .on { color: var(--accent); }
.modal__card h2 { font-size: 20px; margin: 6px 0 4px; }
.modal__sub { color: var(--dim); font-size: 12.5px; margin-bottom: 16px; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.result-grid div { background: #0f1725; border-radius: 10px; padding: 9px 6px; }
.result-grid b { display: block; font-size: 16px; }
.result-grid span { color: var(--dim); font-size: 10.5px; }
.modal__actions { display: flex; gap: 9px; margin-bottom: 10px; }
.btn {
  flex: 1; border-radius: 11px; padding: 12px 0; font-size: 14px; font-weight: 600;
  border: 1px solid var(--line-strong); background: #182234; color: var(--text); cursor: pointer;
}
.btn--primary { background: linear-gradient(140deg, var(--accent), #e0901b); color: #241804; border: 0; }
.btn--ghost { background: #16203200; background: #162032; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(10px);
  background: #223049f2; border: 1px solid var(--line-strong); color: var(--text);
  padding: 9px 18px; border-radius: 10px; font-size: 12.5px;
  opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
