/* 华容道 · 样式（.g-klotski 前缀） */

.g-klotski {
  padding-left: 10px;
  padding-right: 10px;
  gap: 10px;
}

.g-klotski .g-sub { line-height: 1.35; }

.g-klotski .k-board-wrap {
  padding: 2px 0;
}

/* ---------------- 棋盘 ---------------- */
.g-klotski .k-board {
  position: relative;
  width: 100%;
  max-width: min(100%, calc((100dvh - 296px) * 0.8));
  aspect-ratio: 4 / 5;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(242, 209, 107, 0.1), transparent 60%),
    rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 20px 40px -24px rgba(0, 0, 0, 0.9);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.g-klotski .k-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(5, 1fr);
}

.g-klotski .k-cell {
  padding: 2.5px;
}

.g-klotski .k-cell::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.035);
}

/* 出口提示区（曹操的目标位置：最下两行中间两列） */
.g-klotski .k-exit {
  position: absolute;
  left: 25%;
  top: 60%;
  width: 50%;
  height: 40%;
  z-index: 0;
  border-radius: 12px;
  border: 1.5px dashed rgba(242, 209, 107, 0.26);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(242, 209, 107, 0.045), rgba(242, 209, 107, 0.01));
}
.g-klotski .k-exit-t {
  font-size: 10px;
  letter-spacing: 0.24em;
  color: rgba(242, 209, 107, 0.5);
  text-indent: 0.24em;
}

/* ---------------- 棋子 ---------------- */
.g-klotski .k-piece {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  transition: transform 0.14s ease-out;
  will-change: transform;
  touch-action: none;
}
.g-klotski .k-piece.sel { z-index: 4; }
.g-klotski .k-piece.dragging { z-index: 6; }

.g-klotski .k-face {
  position: absolute;
  inset: 2.5px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 6px 14px -9px rgba(0, 0, 0, 0.85);
  transition: box-shadow 0.16s ease, filter 0.16s ease, transform 0.16s ease;
  overflow: hidden;
}
.g-klotski .k-face::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.16), transparent 46%);
  pointer-events: none;
}
.g-klotski .k-name {
  position: relative;
  z-index: 1;
  line-height: 1;
  white-space: nowrap;
}

.g-klotski .k-cao .k-face {
  background: linear-gradient(158deg, #ffedb0 0%, #f2d16b 48%, #c79a34 100%);
  color: #3a2a05;
  border-color: rgba(255, 240, 180, 0.55);
  box-shadow:
    0 0 0 1px rgba(255, 236, 160, 0.4),
    0 10px 24px -10px rgba(242, 209, 107, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.g-klotski .k-zhang .k-face { background: linear-gradient(158deg, #ab9bf2 0%, #7a67d4 55%, #584aa5 100%); }
.g-klotski .k-zhao .k-face { background: linear-gradient(158deg, #93c4ff 0%, #5c8ee0 55%, #3f6db3 100%); }
.g-klotski .k-ma .k-face { background: linear-gradient(158deg, #84e7d1 0%, #45bba1 55%, #2c8b76 100%); color: #07332b; }
.g-klotski .k-huang .k-face { background: linear-gradient(158deg, #ffc98a 0%, #ef9f45 55%, #bd7524 100%); color: #3a2200; }
.g-klotski .k-guan .k-face { background: linear-gradient(158deg, #aef2b7 0%, #5cc477 55%, #2f9e44 100%); color: #08331a; }
.g-klotski .k-pawn .k-face {
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
  color: var(--dim);
  font-weight: 700;
  letter-spacing: 0;
  text-indent: 0;
  border-color: rgba(255, 255, 255, 0.12);
}

.g-klotski .k-piece.sel .k-face {
  box-shadow:
    0 0 0 2px rgba(255, 245, 205, 0.9),
    0 0 0 5px rgba(242, 209, 107, 0.22),
    0 10px 26px -10px rgba(242, 209, 107, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  filter: brightness(1.08);
}
.g-klotski .k-piece.dragging .k-face {
  transform: scale(1.035);
  box-shadow:
    0 0 0 2px rgba(255, 245, 205, 0.55),
    0 16px 30px -12px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  filter: brightness(1.12);
}

/* 可移动落点 */
.g-klotski .k-target {
  position: absolute;
  z-index: 3;
  width: 40px;
  height: 40px;
  margin: 0;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
}
.g-klotski .k-target::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(242, 209, 107, 0.85);
  box-shadow: 0 0 0 5px rgba(242, 209, 107, 0.16), 0 0 14px 2px rgba(242, 209, 107, 0.5);
  animation: kTargetIn 0.18s ease both;
}
@keyframes kTargetIn {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.g-klotski .k-board.is-pressing { cursor: grabbing; }

/* ---------------- 底部提示 ---------------- */
.g-klotski .k-hint {
  text-align: center;
  font-size: 10.5px;
  line-height: 1.5;
  margin-top: -2px;
}

/* ---------------- 弹层 ---------------- */
.k-layer {
  position: fixed;
  inset: 0;
  z-index: 94;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(4, 6, 11, 0.62);
  animation: fadeIn 0.18s ease both;
}

.k-sheet {
  width: min(100%, 352px);
  max-height: min(84vh, 640px);
  overflow-y: auto;
  background: linear-gradient(180deg, #161c2b, #111623);
  border: 1px solid var(--line-2);
  border-radius: 22px;
  padding: 19px;
  box-shadow: 0 34px 80px -18px rgba(0, 0, 0, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: popIn 0.22s cubic-bezier(0.22, 1.1, 0.36, 1) both;
}
.k-sheet-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 10px;
}
.k-sheet-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.3;
}
.k-sheet-sub {
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 4px;
  line-height: 1.5;
}
.k-sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.k-sheet-actions .btn { flex: 1; padding-left: 8px; padding-right: 8px; }

/* 玩法说明 */
.k-guide { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.k-guide-row { font-size: 12.5px; line-height: 1.65; color: var(--dim); }
.k-guide-row b {
  display: inline-block;
  min-width: 34px;
  margin-right: 6px;
  color: var(--accent);
  font-weight: 700;
}

/* 选关列表 */
.k-levels { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.k-lv {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.16s, background 0.16s, transform 0.1s;
}
.k-lv:active { transform: scale(0.985); }
.k-lv.on {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.k-lv-main { flex: 1; min-width: 0; }
.k-lv-name { font-size: 14px; font-weight: 700; }
.k-lv-meta { font-size: 10px; color: var(--faint); margin-top: 2px; line-height: 1.4; }
.k-lv-side { display: flex; align-items: center; gap: 5px; flex: none; }
.k-lv-ok { color: var(--ok); font-size: 12px; font-weight: 700; }

/* 结算 */
.k-win { margin-top: 14px; }
.k-win-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.k-win-stats .stat { background: rgba(255, 255, 255, 0.045); }
.k-win-tip {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--dim);
  text-align: center;
}

@media (max-height: 700px) {
  .g-klotski .k-hint { display: none; }
}
