/* ============================================================
   霓虹数独 style.css —— 深空霓虹玻璃拟物风格，零外部依赖
   ============================================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #e7e9ff;
  background: radial-gradient(circle at 50% 30%, #171a3a, #0b0e20);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* ---------- 整体布局 ---------- */

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px 30px;
}

/* ---------- 顶部栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  color: #0b0e20;
  background: linear-gradient(135deg, #7c5cff, #22d3ee);
  box-shadow: 0 0 16px rgba(124, 92, 255, 0.65);
}

.brand-title {
  font-size: 21px;
  letter-spacing: 3px;
  background: linear-gradient(90deg, #a78bff, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.back-link {
  color: #9fb0ff;
  text-decoration: none;
  font-size: 13px;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.2s, border-color 0.2s;
}

.back-link:hover {
  border-color: rgba(34, 211, 238, 0.6);
  color: #22d3ee;
}

/* ---------- 玻璃面板 ---------- */

.panel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ---------- 状态条 ---------- */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
  margin-bottom: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 64px;
}

.stat-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: #8b90b8;
}

.stat-value {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #dfe3ff;
}

.stat-time .stat-value {
  color: #22d3ee;
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.55);
}

.stat-errors .stat-value.danger {
  color: #ff5ca8;
  text-shadow: 0 0 12px rgba(255, 92, 168, 0.6);
}

/* ---------- 棋盘 ---------- */

.board-wrap {
  position: relative;
  width: min(92vw, 520px);
  margin: 0 auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(124, 92, 255, 0.85);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  box-shadow:
    0 0 30px rgba(124, 92, 255, 0.35),
    inset 0 0 36px rgba(124, 92, 255, 0.08);
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* 3x3 宫之间的粗分隔线 */
.cell.thick-r {
  border-right: 2px solid rgba(124, 92, 255, 0.6);
}

.cell.thick-b {
  border-bottom: 2px solid rgba(124, 92, 255, 0.6);
}

/* 最右列与最下行不画细线，交给棋盘外边框 */
.cell:nth-child(9n) {
  border-right: none;
}

.cell:nth-child(n + 73) {
  border-bottom: none;
}

/* 选中 / 同行同列同宫 / 相同数字 高亮 */
.cell.peer {
  background: rgba(124, 92, 255, 0.11);
}

.cell.same {
  background: rgba(34, 211, 238, 0.16);
}

.cell.selected {
  background: rgba(124, 92, 255, 0.32);
  box-shadow: inset 0 0 0 2px rgba(34, 211, 238, 0.95);
}

/* 数字样式：题目 / 填写 / 提示 / 错误 颜色区分 */
.cell-num {
  position: relative;
  z-index: 2;
  font-size: clamp(18px, 5.4vw, 28px);
  font-weight: 700;
  line-height: 1;
}

.cell.given .cell-num {
  color: #eef1ff;
}

.cell.user .cell-num {
  color: #9a80ff;
  text-shadow: 0 0 10px rgba(124, 92, 255, 0.85);
}

.cell.hinted .cell-num {
  color: #22d3ee;
  text-shadow: 0 0 10px rgba(34, 211, 238, 0.85);
}

.cell.error .cell-num {
  color: #ff5ca8;
  text-shadow: 0 0 10px rgba(255, 92, 168, 0.85);
}

/* 候选数 3x3 小网格 */
.cell-notes {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 2px;
  pointer-events: none;
}

.note {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(9px, 2.5vw, 12px);
  font-weight: 600;
  color: #9fb0ff;
}

/* ---------- 棋盘遮挡层（暂停 / 生成中） ---------- */

.cover {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(11, 14, 32, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.cover-inner {
  text-align: center;
  padding: 10px;
}

.cover-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 3px;
  background: linear-gradient(90deg, #a78bff, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cover-sub {
  margin-top: 8px;
  font-size: 13px;
  color: #8b90b8;
}

.cover-btn {
  margin-top: 20px;
}

/* ---------- 数字键与功能区 ---------- */

.controls {
  margin-top: 14px;
  padding: 14px;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.num-btn {
  height: 52px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #cfd6ff;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, border-color 0.15s;
}

.num-btn:hover {
  border-color: rgba(124, 92, 255, 0.8);
  box-shadow: 0 0 14px rgba(124, 92, 255, 0.35);
}

.num-btn:active {
  transform: translateY(1px);
  background: rgba(124, 92, 255, 0.35);
}

.num-erase {
  font-size: 16px;
  color: #ffb347;
}

.tools {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.tool {
  position: relative;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #c8cded;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.tool:hover {
  border-color: rgba(34, 211, 238, 0.6);
}

.tool:active {
  transform: translateY(1px);
}

.tool:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.tool.active {
  border-color: #22d3ee;
  color: #22d3ee;
  background: rgba(34, 211, 238, 0.12);
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.35);
}

.tool.tool-new {
  color: #ffb347;
}

.tool-badge {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  color: #8b90b8;
}

.tool.active .tool-badge {
  color: #22d3ee;
}

/* ---------- 底部说明 ---------- */

.tips {
  margin: 16px 6px 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.8;
  color: #7e84a8;
}

/* ---------- 全屏遮罩与对话框 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 10, 26, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog {
  width: min(92vw, 460px);
  padding: 26px 24px 24px;
  text-align: center;
  box-shadow: 0 0 50px rgba(124, 92, 255, 0.25);
}

.dialog-title {
  font-size: 25px;
  letter-spacing: 3px;
  background: linear-gradient(90deg, #a78bff, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.dialog-sub {
  margin-top: 8px;
  font-size: 13px;
  color: #8b90b8;
}

/* 难度选择列表 */
.diff-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 22px 0 16px;
}

.diff-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #e7e9ff;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.diff-card:hover {
  border-color: rgba(124, 92, 255, 0.8);
  box-shadow: 0 0 16px rgba(124, 92, 255, 0.3);
}

.diff-card:active {
  transform: translateY(1px);
  background: rgba(124, 92, 255, 0.18);
}

.diff-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.diff-name {
  font-size: 17px;
  font-weight: 700;
}

.diff-meta {
  font-size: 12px;
  color: #8b90b8;
}

.diff-best {
  font-size: 12px;
  color: #8b90b8;
  white-space: nowrap;
}

.diff-best b {
  margin-left: 4px;
  color: #ffb347;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.option-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: #9fa4cc;
  cursor: pointer;
}

.option-line input {
  width: 16px;
  height: 16px;
  accent-color: #7c5cff;
  cursor: pointer;
}

/* 结算展示 */
.result-time {
  margin: 20px auto 4px;
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 34px;
  border-radius: 16px;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.3);
}

.result-label {
  font-size: 12px;
  color: #8b90b8;
  letter-spacing: 2px;
}

.result-value {
  font-size: 30px;
  font-weight: 800;
  color: #22d3ee;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px rgba(34, 211, 238, 0.6);
}

.win-title {
  background: linear-gradient(90deg, #22d3ee, #ff5ca8);
  -webkit-background-clip: text;
  background-clip: text;
}

.fail-title {
  background: linear-gradient(90deg, #ff5ca8, #ffb347);
  -webkit-background-clip: text;
  background-clip: text;
}

#winRecord {
  color: #ffb347;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- 通用按钮 ---------- */

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, #7c5cff, #6d4dff);
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.45);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(124, 92, 255, 0.65);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.btn-ghost:hover {
  border-color: rgba(34, 211, 238, 0.6);
  color: #22d3ee;
}

/* ---------- 手机适配 ---------- */

@media (max-width: 420px) {
  .app {
    padding: 10px 10px 24px;
  }

  .brand-title {
    font-size: 18px;
    letter-spacing: 2px;
  }

  .back-link {
    font-size: 12px;
    padding: 7px 10px;
  }

  .hud {
    padding: 10px 14px;
  }

  .stat-value {
    font-size: 17px;
  }

  .controls {
    padding: 10px;
  }

  .numpad {
    gap: 6px;
  }

  .num-btn {
    height: 48px;
    font-size: 20px;
    border-radius: 12px;
  }

  .num-erase {
    font-size: 15px;
  }

  .tools {
    gap: 6px;
  }

  .tool {
    height: 40px;
    font-size: 12px;
    border-radius: 10px;
  }

  .tool-badge {
    display: none;
  }
}
