.game-wrap {
  width: 100%;
  max-width: 580px;
  padding: 10px 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board-scroll {
  width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  padding: 6px 0;
}

.board {
  position: relative;
  flex: none;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 70%, var(--text));
  background: var(--grid-bg);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.12), 0 3px 8px rgba(15, 23, 42, 0.08);
  border-radius: 14px;
}

.cell {
  position: absolute;
  border: 1px solid var(--cell-line);
  cursor: pointer;
  transition: background 0.14s ease, box-shadow 0.14s ease;
}

.cell-a {
  background: var(--cell-a);
}

.cell-b {
  background: var(--cell-b);
}

.cell.goal-cell {
  background-image: linear-gradient(135deg, color-mix(in srgb, var(--goal) 85%, transparent), transparent 68%);
}

.cell.start-cell {
  z-index: 1;
  background: color-mix(in srgb, var(--start-color) 16%, var(--cell-a));
  box-shadow: inset 0 0 0 3px var(--start-color), inset 0 0 18px color-mix(in srgb, var(--start-color) 24%, transparent);
}

.start-cell-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28);
}

.cell.valid-move-cell:hover {
  background-color: color-mix(in srgb, var(--primary) 12%, var(--cell-a));
}

.goal-gate {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  background: var(--player-color, var(--green));
  box-shadow: 0 0 8px color-mix(in srgb, var(--player-color, var(--green)) 55%, transparent);
}

.goal-gate.top,
.goal-gate.bottom {
  height: 5px;
}

.goal-gate.left,
.goal-gate.right {
  width: 5px;
}

.stone {
  position: absolute;
  border-radius: 50%;
  z-index: 5;
  pointer-events: none;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, 0.35),
    inset 0 -4px 7px rgba(0, 0, 0, 0.4),
    0 4px 7px rgba(0, 0, 0, 0.35),
    0 2px 3px rgba(0, 0, 0, 0.25);
  transition: left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    top 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 11px;
}

.route-stone {
  font-size: clamp(14px, 4vw, 19px);
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.78);
}

.tutorial-stone {
  font-size: 14px;
}

.wall {
  position: absolute;
  z-index: 6;
  border-radius: 4px;
  pointer-events: none;
}

.wall.normal {
  background: var(--wall-color, #1e293b);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
}

.wall.golden {
  background: linear-gradient(135deg, #92400e 0%, #f59e0b 30%, #fde68a 50%, #f59e0b 70%, #92400e 100%);
  box-shadow: 0 0 8px 1px rgba(251, 191, 36, 0.5), 0 2px 6px rgba(0, 0, 0, 0.2);
}

.wall.steel {
  background: linear-gradient(180deg, #eef2f6 0%, #c2ccd8 16%, #94a0af 48%, #5d6878 80%, #3a4250 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.move-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--primary);
  opacity: 0.72;
  z-index: 4;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
  animation: pulseDot 1.2s infinite alternate;
}

@keyframes pulseDot {
  from { transform: translate(-50%, -50%) scale(0.92); opacity: 0.62; }
  to { transform: translate(-50%, -50%) scale(1.16); opacity: 0.95; }
}

.hammer-cell {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

.crate {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ghost-wall {
  position: fixed;
  z-index: 900;
  pointer-events: none;
  border-radius: 4px;
  opacity: 0.85;
}

.ghost-wall.valid {
  background: #22c55e;
  box-shadow: 0 0 12px 2px rgba(34, 197, 94, 0.7);
}

.ghost-wall.invalid {
  background: #ef4444;
  box-shadow: 0 0 12px 2px rgba(239, 68, 68, 0.7);
}

.preview-wall {
  position: absolute;
  z-index: 8;
  border-radius: 4px;
  pointer-events: none;
}

.wall-bar {
  width: 100%;
  max-width: 540px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.wall-handle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: var(--shadow-soft);
  font-weight: 800;
  font-size: 13px;
  touch-action: none;
  cursor: grab;
}

.wall-handle:active {
  cursor: grabbing;
}

.wall-handle .brick {
  width: 26px;
  height: 14px;
  border-radius: 3px;
  background: var(--wall-color, #1e293b);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.25), 0 1px 2px rgba(0, 0, 0, 0.3);
}

.wall-handle .brick.v {
  width: 14px;
  height: 26px;
}

.wall-handle:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wall-handle .cnt {
  background: #ef4444;
  color: #fff;
  border-radius: 9px;
  padding: 1px 7px;
  font-size: 12px;
  font-weight: 900;
}

.hammer-handle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, #fff7ed, #ffedd5);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: var(--shadow-soft);
  font-weight: 800;
  font-size: 13px;
  touch-action: none;
  cursor: pointer;
}

@media (max-width: 420px) {
  .game-wrap {
    padding-inline: 8px;
  }

  .board-scroll {
    padding-block: 4px;
  }
}
