/* puzzle.css — 数谜 ShuMi 通用逻辑谜题页样式 */

:root {
  --accent: #3E8BFF;
  --accent-deep: #16243d;
  --bg: #0B0F16;
  --panel: #111826;
  --panel-2: #0F141D;
  --line: #243044;
  --text: #E8ECF4;
  --text-2: #93A1B8;
  --good: #34D399;
  --bad: #EF4444;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: "Noto Sans SC", system-ui, sans-serif; }

.nav { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--line); background: rgba(11,15,22,.7); }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-weight: 700; }
.logo-text { font-weight: 700; font-size: 18px; }
.nav-links { display: flex; gap: 22px; }
.nav-links a { color: var(--text-2); text-decoration: none; font-size: 14px; }
.nav-links a:hover { color: var(--text); }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 10px 18px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn.big { padding: 14px 34px; font-size: 16px; border-radius: 12px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; }

/* 布局 */
.play { display: grid; grid-template-columns: 1fr 300px; gap: 24px;
  padding: 28px; max-width: 1180px; margin: 0 auto; align-items: start; }

.lobby { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px; text-align: center; }
.ptitle { font-size: 30px; margin: 0 0 8px; }
.pdesc { color: var(--text-2); margin: 0 0 24px; line-height: 1.6; }
.pills { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 26px; }
.pill { border: 1px solid var(--line); background: var(--panel-2); color: var(--text-2);
  padding: 9px 20px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 600; }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.account-line { margin-top: 22px; color: var(--text-2); font-size: 13px; }
.account-line .link-btn { margin-left: 8px; }
#player-tag { color: var(--text); }

.board-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; min-height: 420px; display: flex; flex-direction: column; align-items: center; }
/* 对局中：卡片内边距见 style.css（与广告条同宽、四周 2px） */
.gamebar { width: 100%; display: flex; align-items: center; gap: 22px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 16px; color: var(--text-2); }
.gamebar b { color: var(--text); font-family: "Noto Sans Mono", monospace; }
.board-mount { display: flex; justify-content: center; align-items: center; flex: 1; width: 100%; overflow: auto; position: relative; }

/* 通关结果直接覆盖在棋盘上（不再弹窗） */
.nm-result { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(11,15,22,.72); z-index: 20; backdrop-filter: blur(2px); padding: 16px; }
.nm-result-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 30px 40px; text-align: center; min-width: 280px; box-shadow: 0 24px 64px -12px rgba(0,0,0,.55); }
.nm-result-title { font-size: 26px; font-weight: 700; color: var(--good); margin-bottom: 14px; }
.nm-result-row { margin: 6px 0; color: var(--text-2); }
.nm-result-row b { color: var(--text); font-family: "Noto Sans Mono", monospace; }
.nm-result-score { font-size: 18px; margin-top: 12px; }
.nm-result-score b { color: var(--accent); }
.nm-result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 22px; }

/* 通关按钮条：棋盘上方（不遮挡棋盘，取代旧的覆盖弹窗） */
.nm-winbar { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border: 1px solid rgba(52, 211, 153, .35); border-radius: 12px;
  background: linear-gradient(90deg, rgba(52, 211, 153, .12), rgba(52, 211, 153, .03)); }
.nm-winbar .nm-win-info { color: var(--text-2); font-size: 14px; }
.nm-winbar .nm-win-info b { color: var(--good); font-family: "Noto Sans Mono", monospace; }
.nm-winbar .nm-win-actions { display: flex; gap: 10px; flex-shrink: 0; }
.nm-winbar .btn { padding: 8px 16px; font-size: 13px; }

/* 排行榜 */
.rank-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.sp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sp-title { font-weight: 700; font-size: 14px; }
.rank-list { display: flex; flex-direction: column; gap: 6px; }
.rank-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center;
  padding: 8px 10px; border-radius: 8px; background: var(--panel-2); font-size: 13px; }
.rank-row.me { background: var(--accent-deep); border: 1px solid #2A4A7A; }
.rank-row .rk { color: var(--accent); font-weight: 700; }
.rank-row .rn { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .rs { color: var(--text-2); font-family: "Noto Sans Mono", monospace; }
.rank-empty, .rank-hint { color: var(--text-2); font-size: 12px; padding: 8px; text-align: center; }

/* 登录弹窗 */
.login-pop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none;
  align-items: center; justify-content: center; z-index: 50; }
.login-pop.show { display: flex; }
.lp-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; width: 320px; text-align: center; }
.lp-card h3 { margin: 0 0 18px; }
.lp-input { width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); margin-bottom: 10px; font-size: 14px; }
.lp-err { color: var(--bad); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* 通关浮层 */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: none;
  align-items: center; justify-content: center; z-index: 60; }
.overlay.show { display: flex; }
.ov-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 34px 40px; text-align: center; min-width: 300px; }
.ov-title { font-size: 26px; font-weight: 700; color: var(--good); margin-bottom: 16px; }
.ov-row { margin: 6px 0; color: var(--text-2); }
.ov-row b { color: var(--text); }
.ov-score { font-size: 18px; margin-top: 12px; }
.ov-score b { color: var(--accent); }
.ov-actions { display: flex; gap: 12px; justify-content: center; margin-top: 22px; }

/* ===== 数织 Nonogram ===== */
/* 布局：corner / top clues / left clues / board 四个独立区域，
   提示区不属于棋盘，无网格线；棋盘单独 grid 并支持每 5 格加粗线。 */
.nonogram-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0;
  user-select: none;
}

.nm-grid {
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  gap: 0;
  align-items: start;
  justify-items: start;
}

.nm-corner {
  grid-row: 1; grid-column: 1;
}

/* ============================================================
   提示区：不画格子，把棋盘的网格线向上 / 向左「延长」出去
   · 上方深度 = 这一局里提示数最多的那一列，最顶端那条线封口
   · 左侧宽度 = 提示数最多的那一行，最左边那条线封口
   · 宽/高含棋盘 2px 边框，用 padding 抵消，格子与棋盘格共用同一条线
   ============================================================ */
.nm-top-clues {
  grid-row: 1; grid-column: 2;
  justify-self: start;
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), var(--cell, 26px));
  width: calc(var(--cols, 10) * var(--cell, 26px) + 4px);
  height: calc(var(--depth-c, 1) * var(--cell, 26px) + 2px);
  padding: 2px 2px 0;
  box-shadow:
    inset 0 2px 0 #6E81A0,   /* 顶端封口线（以提示数最多的那一条为界） */
    inset 2px 0 0 #6E81A0,   /* 左边界，接棋盘左边框 */
    inset -2px 0 0 #6E81A0;  /* 右边界，接棋盘右边框 */
}

.nm-left-clues {
  grid-row: 2; grid-column: 1;
  justify-self: end;
  display: grid;
  grid-template-rows: repeat(var(--rows, 10), var(--cell, 26px));
  width: calc(var(--depth-r, 1) * var(--cell, 26px) + 2px);
  height: calc(var(--rows, 10) * var(--cell, 26px) + 4px);
  padding: 2px 0 2px 2px;
  box-shadow:
    inset 2px 0 0 #6E81A0,   /* 最左封口线（以提示数最多的那一条为界） */
    inset 0 2px 0 #6E81A0,   /* 顶端封口线，接棋盘上边框 */
    inset 0 -2px 0 #6E81A0;  /* 下边界，接棋盘下边框 */
}

/* 一列提示：整列满深度，只画右竖线（= 棋盘列线的延长），数字贴着棋盘往上叠 */
.nm-col-clue {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  box-sizing: border-box;
  box-shadow: inset -1px 0 0 #46587A;
  cursor: pointer;
}

.nm-col-clue.thick-r { box-shadow: inset -2px 0 0 #6E81A0; }

/* 一行提示：整行满宽度，只画下横线（= 棋盘行线的延长），数字贴着棋盘往左排 */
.nm-row-clue {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  box-sizing: border-box;
  box-shadow: inset 0 -1px 0 #46587A;
  cursor: pointer;
}

.nm-row-clue.thick-b { box-shadow: inset 0 -2px 0 #6E81A0; }

/* 提示数字本身不带任何格子边框，直接落在延长线划出的空位里 */
.nm-col-clue span,
.nm-row-clue span {
  flex: 0 0 auto;
  /* 提示数之间收紧一点：占 0.84 格，仍以格子中心对齐（列宽居中 / 行高居中） */
  width: calc(var(--cell, 26px) * 0.84);
  height: calc(var(--cell, 26px) * 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell, 26px) * 0.54);
  color: #F2F6FC;
  font-weight: 700;
  font-family: "Noto Sans Mono", monospace;
  line-height: 1;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  transition: color .12s, background .12s;
  overflow: visible;
}

/* 两位数（10~19、20+）：字号略收、字距微压，保证「23」「27」在单格内完整显示 */
.nm-col-clue span.wide,
.nm-row-clue span.wide {
  font-size: calc(var(--cell, 26px) * 0.50);
  letter-spacing: -0.06em;
}

.nm-col-clue span.done,
.nm-row-clue span.done {
  color: var(--accent);
  background: rgba(62, 139, 255, 0.16);
  border-radius: 3px;
}

/* 中间解题棋盘 */
.nm-board {
  grid-row: 2; grid-column: 2;
  justify-self: start;
  align-self: start;
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), var(--cell, 26px));
  grid-template-rows: repeat(var(--rows, 10), var(--cell, 26px));
  border: 2px solid #6E81A0;
  background: var(--panel);
}

.nm-cell {
  border-right: 1px solid #46587A;
  border-bottom: 1px solid #46587A;
  background: var(--panel);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .08s;
}

.nm-cell:nth-child(-n+var(--cols)) { border-top: none; }

.nm-cell.thick-r {
  border-right-width: 2px;
  border-right-color: #6E81A0;
}
.nm-cell.thick-b {
  border-bottom-width: 2px;
  border-bottom-color: #6E81A0;
}

/* 悬停高亮：当前行、列以及对应提示区（加深 + 暖琥珀色，明显区别于蓝色棋盘与白色填充） */
.nm-cell.highlight {
  box-shadow: inset 0 0 0 1000px rgba(245, 158, 11, 0.32);
}
.nm-col-clue.highlight,
.nm-row-clue.highlight {
  background: rgba(245, 158, 11, 0.24);
  color: #FFE2B0;
}

/* 涂白（填充）格：白色面积基本不变，用内嵌 1px 细线留出边框，
   保证涂白后格线与每 5 格粗线仍然清晰可见 */
.nm-cell.filled {
  background: var(--text);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .38);
}
.nm-cell.marked { background: var(--panel-2); }
.nm-cell.marked::after {
  content: "✕";
  color: var(--text-2);
  font-size: max(10px, calc(var(--cell, 26px) * 0.55));
}
.nm-cell.done { cursor: default; }

/* 右侧模式工具栏（离棋盘右侧边缘 3 个格子） */
.nm-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-left: calc(var(--cell, 26px) * 3);
  padding-left: 4px;
}
.nm-tool-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-2);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: background .12s, border-color .12s, color .12s;
}
.nm-tool-btn:hover { border-color: var(--accent); color: var(--text); }
.nm-tool-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.nm-tool-btn svg { width: 18px; height: 18px; }

/* 小屏适配 */
@media (max-width: 860px) {
  .play { grid-template-columns: 1fr; padding: 16px; }
  .rank-panel { display: none; }
  .board-wrap { padding: 12px; }
}

/* 历史谜题重玩列表（棋盘下方） */
.nm-replay { margin-top: 18px; padding-top: 14px; border-top: 1px solid #46587A; max-width: 100%; }
.nm-replay-title { font-size: 13px; color: #9FB2CE; margin-bottom: 8px; letter-spacing: .04em; }
.nm-replay-list { display: flex; flex-wrap: wrap; gap: 6px; }
.nm-replay-item {
  background: #16202E; color: #DCE4F2; border: 1px solid #34435C; border-radius: 6px;
  padding: 5px 10px; font-size: 12px; cursor: pointer; transition: .15s;
}
.nm-replay-item:hover { background: #1d2a3a; border-color: #E85D04; color: #fff; }
.nm-replay-empty { font-size: 12px; color: #6E81A0; }

/* 历史题赞助弹窗（未赞助玩家选历史期时） */
.sponsor-pop {
  position: fixed; inset: 0; z-index: 9998;
  display: none; align-items: center; justify-content: center;
  background: rgba(6, 9, 14, .66); backdrop-filter: blur(2px);
}
.sponsor-pop.show { display: flex; }
.sponsor-card {
  width: 360px; max-width: 92vw; text-align: center;
  background: var(--surface, #11151c); border: 1px solid var(--line, #222a36);
  border-radius: 18px; padding: 24px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .6);
}
.sponsor-title { font-size: 18px; font-weight: 700; color: var(--text, #e8ecf4); margin-bottom: 10px; }
.sponsor-desc { font-size: 13px; line-height: 1.7; color: var(--text-2, #9aa6b6); margin: 0 0 18px; }
.sponsor-actions { display: flex; gap: 10px; justify-content: center; }
.sponsor-actions .btn { flex: 1; }
