/* 推箱子 · 专属样式（选择器统一 .g-sokoban 前缀，墙/地板/目标/箱/玩家全部 CSS 绘制） */

.g-sokoban .g-title { font-size: 13px; }
.g-sokoban .g-head-right { gap: 6px; }
.g-sokoban .sk-board-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------- 棋盘 ---------------- */
.g-sokoban .sk-board {
  position: relative;
  flex: none;
  border-radius: 16px;
  background: #0b0f17;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 22px 60px -26px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    0 0 0 5px rgba(255, 180, 84, 0.035);
  overflow: hidden;
  touch-action: none;
  --tile: 40px;
  --cols: 9;
  --rows: 9;
}
.g-sokoban .sk-cells {
  position: absolute;
  inset: 0;
  display: grid;
}
.g-sokoban .sk-cell {
  position: relative;
  width: var(--tile);
  height: var(--tile);
}
.g-sokoban .sk-cell.wall::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 4px;
  background: linear-gradient(158deg, #2e3a4f 0%, #202a3a 55%, #18202d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -2px 0 rgba(0, 0, 0, 0.38);
}
.g-sokoban .sk-cell.floor::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 4px;
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.016));
}
.g-sokoban .sk-cell.floor.alt::before {
  background: linear-gradient(158deg, rgba(255, 255, 255, 0.032), rgba(255, 255, 255, 0.008));
}
.g-sokoban .sk-cell.goal::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34%;
  height: 34%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 180, 84, 0.55);
  background: radial-gradient(circle, rgba(255, 180, 84, 0.42), rgba(255, 180, 84, 0.05) 72%);
  box-shadow: 0 0 14px rgba(255, 180, 84, 0.28);
}

/* ---------------- 精灵（箱子 / 玩家） ---------------- */
.g-sokoban .sk-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.g-sokoban .sk-box,
.g-sokoban .sk-player {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--tile);
  height: var(--tile);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(calc(var(--tile) * var(--x, 0)), calc(var(--tile) * var(--y, 0)));
  transition: transform 0.12s cubic-bezier(0.3, 0.8, 0.4, 1);
  will-change: transform;
}
.g-sokoban .sk-box::before {
  content: "";
  width: 76%;
  height: 76%;
  border-radius: 15%;
  background: linear-gradient(152deg, #ffd18a 0%, #f0a03c 46%, #b96a1e 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    inset 0 -3px 0 rgba(0, 0, 0, 0.28),
    0 5px 12px -5px rgba(224, 123, 42, 0.8);
  transition: background 0.16s ease, box-shadow 0.2s ease;
}
.g-sokoban .sk-box::after {
  content: "";
  position: absolute;
  width: 40%;
  height: 40%;
  border-radius: 12%;
  border: 2px solid rgba(126, 66, 12, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.g-sokoban .sk-box.on::before {
  background: linear-gradient(152deg, #fff0c4 0%, #ffc266 45%, #e08a2e 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 0 rgba(0, 0, 0, 0.22),
    0 0 0 2px rgba(255, 236, 190, 0.55),
    0 0 24px 4px rgba(255, 180, 84, 0.55);
}
.g-sokoban .sk-player::before {
  content: "";
  width: 62%;
  height: 62%;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 28%, #cde9ff 0%, #6fb0ff 42%, #3c72dd 100%);
  box-shadow:
    inset 0 -3px 6px rgba(0, 0, 0, 0.28),
    0 5px 14px -5px rgba(111, 176, 255, 0.85);
}
.g-sokoban .sk-player-core {
  position: absolute;
  left: 36%;
  top: 42%;
  width: calc(var(--tile) * 0.085);
  height: calc(var(--tile) * 0.085);
  border-radius: 50%;
  background: rgba(8, 14, 28, 0.72);
  box-shadow: calc(var(--tile) * 0.15) 0 0 rgba(8, 14, 28, 0.72);
}

/* ---------------- 动画 ---------------- */
.g-sokoban .sk-board.bump { animation: skBump 0.2s ease; }
@keyframes skBump {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-2px); }
  65% { transform: translateX(2px); }
}
.g-sokoban .sk-board.win .sk-box::before {
  animation: skBoxWin 0.62s cubic-bezier(0.22, 0.9, 0.3, 1.2) both;
}
@keyframes skBoxWin {
  0% { transform: scale(1); }
  40% { transform: scale(1.16) rotate(-4deg); }
  70% { transform: scale(0.96) rotate(2deg); }
  100% { transform: scale(1); }
}

/* ---------------- HUD ---------------- */
.g-sokoban .sk-hud {
  flex: none;
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  min-height: 22px;
}
.g-sokoban .sk-hud .num { color: var(--text); font-size: 13.5px; }
.g-sokoban .sk-sep { color: var(--faint); margin: 0 2px; }
.g-sokoban .sk-badges { display: flex; align-items: center; gap: 6px; }

/* ---------------- 方向键（4 个大按钮） ---------------- */
.g-sokoban .sk-dpad {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 58px 58px;
  gap: 8px;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}
.g-sokoban .sk-dir {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035));
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  touch-action: manipulation;
  transition: transform 0.08s ease, background 0.12s ease, border-color 0.12s ease;
}
.g-sokoban .sk-dir:active {
  transform: scale(0.95);
  background: color-mix(in srgb, var(--accent) 20%, var(--surface-2));
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}
.g-sokoban .sk-dir-up { grid-column: 2; grid-row: 1; }
.g-sokoban .sk-dir-left { grid-column: 1; grid-row: 2; }
.g-sokoban .sk-dir-down { grid-column: 2; grid-row: 2; }
.g-sokoban .sk-dir-right { grid-column: 3; grid-row: 2; }
.g-sokoban .sk-dir-g { transform: translateY(-1px); }

/* ---------------- 选关弹层 ---------------- */
.sk-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 6, 11, 0.72);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn 0.18s ease both;
}
.sk-modal-card {
  width: min(100%, 420px);
  max-height: min(88vh, 760px);
  overflow-y: auto;
  background: linear-gradient(180deg, #161c2b, #111623);
  border: 1px solid var(--line-2);
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 34px 80px -18px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: popIn 0.24s cubic-bezier(0.22, 1.1, 0.36, 1) both;
}
.sk-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.sk-modal-head .dialog-title { margin-bottom: 0; }
.sk-levels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.sk-lv {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 48px;
  padding: 4px 2px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  touch-action: manipulation;
  transition: transform 0.08s ease, background 0.16s, border-color 0.16s;
}
.sk-lv:active { transform: scale(0.95); }
.sk-lv-n {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.sk-lv-b {
  font-size: 9px;
  line-height: 1.15;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  min-height: 10px;
}
.sk-lv.done {
  border-color: rgba(62, 207, 142, 0.35);
  background: rgba(62, 207, 142, 0.08);
}
.sk-lv.done .sk-lv-n { color: var(--ok); }
.sk-lv.current {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.sk-lv.current .sk-lv-n { color: var(--accent); }
.sk-modal-hint {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--faint);
  text-align: center;
}

/* ---------------- 小屏适配 ---------------- */
@media (max-width: 359px) {
  .g-sokoban .sk-head-right .btn { padding: 6px 8px; font-size: 11.5px; }
  .g-sokoban .sk-dpad { grid-template-rows: 52px 52px; }
  .g-sokoban .sk-dir { min-height: 52px; }
}
